Microsoft Edge TTS, no need for app_key

Microsoft Edge TTS for Home Assistant

This component is based on the TTS service of Microsoft Edge browser, no need to apply for app_key.

Install

Download and copy custom_components/edge_tts folder to custom_components folder in your HomeAssistant config folder

# Auto install via terminal shell
wget -q -O - https://cdn.jsdelivr.net/gh/al-one/hass-xiaomi-miot/install.sh | DOMAIN=edge_tts REPO_PATH=hasscc/hass-edge-tts ARCHIVE_TAG=main bash -

Config

# configuration.yaml
tts:
  - platform: edge_tts
    language: zh-CN # Default language or voice (Optional)

Configure default options:

tts:
  - platform: edge_tts
    service_name: xiaomo_say
    language: zh-CN-XiaomoNeural
    style: cheerful
    styledegree: 2
    role: Girl

Supported languages

Using

Options

  • voice
  • style
  • styledegree: 0.01 - 2, only for zh-CN
  • role: only for zh-CN-XiaomoNeural zh-CN-XiaoxuanNeural
    • Girl
    • Boy
    • YoungAdultFemale
    • YoungAdultMale
    • OlderAdultFemale
    • OlderAdultMale
    • SeniorFemale
    • SeniorMale
  • pitch / rate / volume

Basic example

service: tts.edge_tts_say
data:
  entity_id: media_player.your_player_entity_id
  message: Hello
  language: zh-CN-XiaoxiaoNeural # Language or voice (Optional)

Full example

service: tts.edge_tts_say
data:
  entity_id: media_player.your_player_entity_id
  message: 吃葡萄不吐葡萄皮,不吃葡萄倒吐葡萄皮
  language: zh-CN
  cache: true
  options:
    voice: zh-CN-XiaomoNeural
    style: cheerful
    styledegree: 2
    role: Girl
    pitch: +0Hz
    rate: +0%
    volume: +10%

Curl example

curl -X POST -H "Authorization: Bearer <ACCESS TOKEN>" \
     -H "Content-Type: application/json" \
     -d '{"platform": "edge_tts", "message": "早上好", "language": "zh-CN-XiaoxuanNeural", "cache": false, "options": {"style": "cheerful", "role": "Boy"}}' \
     http://home-assistant.local:8123/api/tts_get_url
3 Likes

Appreciate the good work. Anyone interested in this can try the sample voices from this url. It illustrates all the styles of the voices including speed and pitch.

Hey @alone

Awesome project here, after I figured out the mis-type I made, it works perfectly!

I don’t know if it is possible or not, but if it is, could you add the en-US-DavisNeural voice to the integration?

Thanks again for the great integration!

I can’t get this to work.
Alexa complains, says:
Sorry, text to speech can only be called with the notify dot Alexa underscore media service. Please see the Alexa underscore media wiki for details.

https://github.com/hasscc/hass-edge-tts

# Auto install via terminal shell
wget -O - https://raw.githubusercontent.com/hasscc/get/main/get | DOMAIN=edge_tts REPO_PATH=hasscc/hass-edge-tts ARCHIVE_TAG=main bash -

[core-ssh custom_components]$ wget -O - https://raw.githubusercontent.com/hasscc/get/main/get | DOMAIN=edge_tts REPO_PATH=hasscc/hass-edge-tts ARCHIVE_TAG=main bash -
Connecting to raw.githubusercontent.com (185.199.109.133:443)
writing to stdout
-                    100% |********************************|  3970  0:00:00 ETA
written to stdout
INFO: Archive URL: https://github.com/hasscc/hass-edge-tts/archive/main.zip
INFO: Trying to find the correct directory...
INFO: Found Home Assistant configuration directory at '/config'
INFO: Changing to the custom_components directory...
INFO: Downloading...
Connecting to github.com (140.82.113.4:443)
Connecting to codeload.github.com (140.82.112.9:443)
saving to '/config/custom_components/main.zip'
main.zip             100% |********************************|  8333  0:00:00 ETA
'/config/custom_components/main.zip' saved
INFO: Unpacking...
INFO: Removing temp files...
INFO: Installation complete.
INFO: 安装成功!

INFO: Remember to restart Home Assistant before you configure it.
INFO: 请重启 Home Assistant
[core-ssh custom_components]$ ls
alexa_media     hacs            xiaomi_miot
edge_tts        old.install.sh
[core-ssh custom_components]$ 


restart, then:
add edge_tts to configuration.yaml:
# Text to speech
tts:
  - platform: google_translate

  - platform: edge_tts
    language: en-US # Default language or voice (Optional)
    
test in Developer Tools:

service: tts.edge_tts_say
data:
  entity_id: media_player.william_s_office_echo_dot
  message: >-
    You can replace this text with any text you wish. You can either write in
    this text box or paste your own text here.  Try different languages and
    voices. Change the speed and the pitch of the voice. You can even tweak the
    SSML (Speech Synthesis Markup Language) to control how the different
    sections of the text sound. Click on SSML above to give it a try!  Enjoy
    using Text to Speech!
  options:
    voice: Eric (neural)

Alexa complains, says:
Sorry, text to speech can only be called with the notify dot Alexa underscore media service. Please see the Alexa underscore media wiki for details.

Thanks a lot for your great integration! This works very well for me with Google Nest devices. However, I have two questions:

  1. The language/role setting did not work for me. Whatever role I choose, I always hear the same voice, likely YoungAdultFemale. Also the sound does not change with the language set to either Xiaomo or Xiaoxiao.
  2. I found that Azure TTS actually support prepending sound effect before the speech by SSML (doc). Is there a way to achieve this with this integration?

Thanks in advance!

EDIT: seems like 2 is no longer possible: edge-tts