Introduction to Microsoft Edge TTS for Home Assistant
The "Microsoft Edge TTS for Home Assistant" is an integration that enables text-to-speech (TTS) capabilities within Home Assistant by leveraging the TTS service found in the Microsoft Edge browser. Unlike many other TTS services, it doesn't require any app_key
for use, making it an easy and accessible option for users who wish to add voice synthesis to their smart home system.
Installation
To get started with Microsoft Edge TTS for Home Assistant, users need to download and copy the custom_components/edge_tts
directory into their Home Assistant custom_components
configuration folder. For an automatic installation, users can run the following terminal command:
wget -O - https://hacs.vip/get | DOMAIN=edge_tts REPO_PATH=hasscc/hass-edge-tts ARCHIVE_TAG=main bash -
Configuration
Setting up the TTS service requires a simple addition to the Home Assistant configuration.yaml
file:
tts:
- platform: edge_tts
language: zh-CN # Default language or voice (Optional)
Custom Configuration Options
Users can further customize the service by configuring default options, such as defining a custom service name, choosing a default language or voice, and adjusting the volume level.
tts:
- platform: edge_tts
service_name: xiaomo_say # service: tts.xiaomo_say
language: zh-CN-XiaoxiaoNeural
volume: +10%
Supported Languages and Voices
A variety of languages and voices are supported, allowing for diverse and flexible TTS outputs. Users can find more details about supported speaking languages and available voices through the provided links in the documentation.
Usage
Home Assistant offers two main ways to utilize the TTS service: through a call service and via the REST API.
Options
The service supports several customization options, allowing users to modify the voice attributes such as voice
, pitch
, rate
, and volume
to suit their needs. Note that some options like style
, styledegree
, role
, and contour
are no longer supported.
Example Scenarios
Here are some YAML examples demonstrating how to use the Microsoft Edge TTS service within Home Assistant:
Basic Example
A straightforward use case where a message is played on a media player entity:
service: tts.edge_tts_say
data:
entity_id: media_player.your_player_entity_id
message: Hello
language: zh-CN-XiaoyiNeural # Language or voice (Optional)
Comprehensive Example
This example includes additional parameters like caching the TTS file and setting specific voice configurations:
service: tts.edge_tts_say
data:
entity_id: media_player.your_player_entity_id
message: 吃葡萄不吐葡萄皮,不吃葡萄倒吐葡萄皮
language: zh-CN
cache: true
options:
voice: zh-CN-XiaoyiNeural
rate: +0%
volume: +10%
Curl Example
Sending TTS requests to Home Assistant via a curl command is also supported:
curl -X POST -H "Authorization: Bearer <ACCESS TOKEN>" \
-H "Content-Type: application/json" \
-d '{"platform": "edge_tts", "message": "欢迎回家", "language": "zh-CN-XiaoyiNeural", "cache": true, "options": {"volume": "+10%"}}' \
http://home-assistant.local:8123/api/tts_get_url
Acknowledgments
Special thanks go to projects like https://github.com/rany2/edge-tts and https://github.com/ag2s20150909/TTS for their valuable contributions that helped shape this integration.