Giter Site home page Giter Site logo

ha-rhvoice's Introduction

RHVoice component for Home Assistant

hacs_badge Validate with hassfest Validate with HACS action

The rhvoice integration uses RHVoice Text-to-Speech (TTS) engine to read a text with natural sounding voices.

Installation

  1. Run rhvoice-rest Docker container (choose your CPU architecture):

    aarch64: docker run -d -p 8080:8080 aculeasis/rhvoice-rest:arm64v8

    armv7l: docker run -d -p 8080:8080 aculeasis/rhvoice-rest:arm32v7

    x86_64: docker run -d -p 8080:8080 aculeasis/rhvoice-rest:amd64

    Or use RHVoice add-on. Only aarch64 and x64 are supported.

  2. Install the integration to Home Assistant: use HACS or copy the contents of custom_components/rhvoice/ to <your config dir>/custom_components/rhvoice/.

  3. Configure in the Home Assistant configuration.yaml (See the Configuration and Configuration Options sections below)

  4. Restart Home Assistant.

Configuration

To enable text-to-speech with RHVoice, add at a minimum the following lines to your Home Assistant's configuration.yaml file:

tts:
  - platform: rhvoice
    host: <server hostname, domain name or IP address>
    port: 8080

Full configuration example:

tts:
  - platform: rhvoice
    host: <server hostname or IP address>
    port: 8080
    format: 'mp3'
    pitch: 50
    rate: 50
    voice: 'anna'
    volume: 50

Configuration Options

  • host: (string) (Required)

    This is the hostname, domain name or IP address that the rhvoice-rest container can be reached at. If you use domain name that is reachable on the Internet for Home Assistant, enter that here. Use localhost for RHVoice add-on.

  • port: (string) (Optional)

    This is the port that the rhvoice-rest container can be reached at.

    Default value: 8080

  • ssl: (boolean) (Optional)

    Use HTTPS instead of HTTP to connect.

    Default value: false

  • verify_ssl: (boolean) (Optional)

    Enable or disable SSL certificate verification. Set to false if you have a self-signed SSL certificate and haven't installed the CA certificate to enable verification.

    Default value: true

  • format: (string) (Optional)

    This is the file format used for the TTS files created.

    Default value: mp3

    Allowed values: wav|mp3|opus|flac

  • pitch: (string) (Optional)

    This adjust the sound frequency of the TTS voice, lower or higher.

    Default value: 50

    Allowed values: 0 to 100

  • rate: (string) (Optional)

    This adjust the talking speed of the TTS voice, slower or faster.

    Default value: 50

    Allowed values: 0 to 100

  • voice: (string) (Optional)

    This is the voice that is used to create the TTS files. Voices are connected with a language. For best results select a voice for the text language you will use.

    Default value: anna (russian)

    Allowed values:

    Language Voices
    Albanian hana
    American English alan, bdl, clb, evgeniy-eng, lyubov, slt
    Czech zdenek
    Esperanto spomenka
    Georgian natia
    Kyrgyz azamat, nazgul
    Macedonian kiko, suze
    Polish alicja, cezary, magda, michal, natan
    Brazilian Portuguese letícia-f123
    Russian aleksandr, aleksandr-hq, anna, arina, artemiy, elena,
    evgeniy-rus, irina, mikhail, pavel, tatiana, timofey,
    umka, victoria, vitaliy, vitaliy-ng, vsevolod, yuriy
    Slovak ondro
    Tatar talgat
    Ukrainian anatol, marianna, natalia, volodymyr
    Uzbek sevinch
  • volume: (string) (Optional)

    This adjusts the volume of the voice in TTS files created, softer or louder.

    Default value: 50

    Allowed values: 0 to 100

Tips

You can override configuration with service options

service: tts.rhvoice_say
data:
  entity_id: media_player.main
  message: The cake is a lie
  options:
    format: mp3
    pitch: 32
    rate: 64
    voice: slt
    volume: 16

Other

You can buy me a coffee via Bitcoin donation: bc1qd6khey9xkss6vgd6fqpqdyq4lehtepajkcf256

ha-rhvoice's People

Contributors

definitio avatar frederickjh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ha-rhvoice's Issues

Произношение десятичного разделителя.

В Home Assistant в качестве разделителя целой и дробной частей числа испльзуется точка ("американский" стандарт), и при произношении такого числа эта точка "проглатывается".
Например, текст "температура поднялась выше 2.4 градуса" звучит как "...двух четыре градуса".
Если же используется разделитель по "российскому" стандарту - т.е., запятая, то всё нормально: фраза "...2,4 градуса" звучит как "...двух целых и четырёх десятых градуса".
Соответственно, встает дилемма - либо

  1. заставить Home Assistant выдавать числа (значения переменных) с запятой в качестве десятичного разделителя.
    ...либо
  2. научить RHVoice интерпретировать точку внутри числа как десятичный разделитель.

Недоговаривание

Столкнулся с проблемой "недоговаривания". То есть, заданная фраза проговаривается не до конца, а обрезается за полслова-слово до конца. Временно выхожу из положения, добавляя в конец каждой задаваемой фразы "мусор" из 4-5 согласных. Например "Доброе утро! ввввв".
Конфигурация такая: Home Assistant установлен на PC с Ubuntu 20.04. В качестве аудиоплеера используется MPD на другом компьютере (Raspberry Pi).
Сначала я грешил на то, что фраза формируется (т.е., TTS-озвучивается) не полностью. Но оказалось, что это не так - сгенерированные MP3-файлы содержат полные фразы и на PC под Windows воспроизводятся полностью.
Потом я решил, что проблема в MPD. Однако, сторонние MP3-файлы там воспроизводятся нормально и до конца. Думал, что проблема вызвана неполным скачиванием файла через http(s). Однако файл скачивается полностью.
И вот, что оказалось. Если сгенерированный файл просто взять из папки Home Assistant'а и "скормить" в MPD вручную, то он тоже воспроизводится не до конца! Получается, что проблема в особенностях генератора MP3, используемого в RHVoice - то ли какие-то нарушения формата MP3, то ли не тот кодек, то ли еще что-то.
В-общем, надо бы как-то решить эту проблему.

Не запускается контейнер с rhvoice

HA на Rasspberry Pi 4B, установлен Mopidy, через google_translate синтез работает. Пытаюсь запустить контейнер с rhvoice, но он не запускается. Запускал командой "docker run -d -p 8080:8080 aculeasis/rhvoice-rest:arm32v7", контейнер создался, но не работает. В логе:

Setting trap PID 1
Fatal Python error: pyinit_main: can't initialize time
Python runtime state: core initialized
PermissionError: [Errno 1] Operation not permitted
Current thread 0xb6f31460 (most recent call first):

Change voice dynamically

It is need to be able to change the voice (e.g., "anna", "aleksandr", etc.) as option when generating each individual message.

RHVoice in Home Assistant

  1. rhvoice-rest Docker container установлен.
  2. В браузере через "http://192.168.1.250:8080/say?text=123" все работает - произносит "сто двадцать три"

Как пользоваться в Home Assistant?
В configuration.yaml:
tts:

  • platform: rhvoice
    voice: anna
    host: <192.168.1.250>

Но если пробовать Developer Tools - Call Service tts.rhvoice_say c параметром Привет, то возвращает ошибку ""Failed to call service tts/rhvoice_say. expected dict for dictionary value @ data['service_data']. Got 'Привет'""

unsupported

Hello. Great integration, love it, but Supervised is fighting about an unsupported container. Can this be fixed?

Improve Documentation regarding configuration

Hi!

I have now gotten ha-rhvoice configured on my Home Assistant setup. I am using a domain name with a SSL certificate. Currently from the documentation it is not clearly evident how to correctly set this up. I have the following in my Home Assistant configuration.yml file:

# Text to speech
tts:
  - platform: rhvoice
    host: example.com
    cache: true
    cache_dir: /tmp/tts
    time_memory: 300
    service_name: rhvoice_say
    # Optional
    port: 8880
    # Optional, wav|mp3|opus|flac
    format: 'mp3'
    # Optional, 0..100
    pitch: 50
    # Optional, 0..100
    rate: 50
    # Optional, default is 'anna' (russian)
    voice: 'alan'
    # Optional, 0..100
    volume: 100

Previously I had host: set to the LAN IP address of the computer running Home Assistant via docker and the aculeasis/rhvoice-rest container. I also had port: set to 8080. However because I am using port 8080 for something else (and have it forwarded to a different computer on the LAN) I have forwarded port 8880 on my router to the Home Assistant computer's port 8080.

So if I am understanding this correctly Host: and Port: need to be set to the hostname and port that the rhvoice-rest container can be reached at.

If that is true then I suggest changing the configuration example in the documentation to the following:

tts:
  - platform: rhvoice
    # This is the hostname or domain name that the rhvoice-rest container can be reached at.
    host: <server hostname or IP address>
    # This is the port that the rhvoice-rest container can be reached at. 
    # For external access you need to forward this port on your router to the computer running the rhvoice-rest container.
    port: 8080
    # Optional, wav|mp3|opus|flac
    format: 'mp3'
   # Optional, 0..100
    pitch: 50
   # Optional, 0..100
    rate: 50
   # Optional, default is 'anna' (russian)
    voice: 'anna'
    # Optional, 0..100
    volume: 50

In addition to the comments I have moved the comments to the line above the YAML, as Home Assistant does not like comments after the YAML.

I am willing to submit a pull request. If you would like this structured differently, say with shorter comments in the configuration and a separate section explaining the configuration file options I can do this too.

Frederick

Hard coded http:// does not allow using https:// with Text to Speech (tts) Say Service

I have my Home Assistant setup to use a public domain name using an SSL certificate. Sending TTS notifications to the Home Assistant Android app works.

What does not work is using the TTS Say service. If I try to send these either using the Developer Tools > Services

image

or via the popup from clicking on the three dots in a media player in lovelace

image

image

I get errors like these in the log:

 2021-01-07 00:33:41 ERROR (MainThread) [custom_components.rhvoice.tts] Error 400 on load URL http://example.com:8880/say?text=When+pigs+can+fly!&voice=alan&format=mp3&rate=50&pitch=50&volume=100
 2021-01-07 00:33:41 ERROR (MainThread) [homeassistant.components.tts] Error on init TTS: No TTS from rhvoice for 'When pigs can fly!'

In tts.py on line 79 the http is hard coded:

        self._url = f'http://{conf.get(CONF_HOST)}:{conf.get(CONF_PORT)}/say'

If I change the http to https on line 79 of tts.py, clear the TTS cache and restart Home Assistant, then I can use the TTS say service in Home Assistant.

        self._url = f'https://{conf.get(CONF_HOST)}:{conf.get(CONF_PORT)}/say'

Is there a way to get the protocol from Home Assistant? I see that the host and port are brought in from Home Assistant. Maybe you can get the protocol (http or https) too.

Thanks for looking in to this!
Frederick

Supervisor reports that image is not supported.

Please see a fragment from Supervisor's log:
21-10-30 11:52:51 WARNING (MainThread) [supervisor.resolution.evaluations.base] Found images: {'portainer/portainer', 'rhvoice-rest'} which are not supported, remove these from the host! (more-info: https://www.home-assistant.io/more-info/unsupported/software)

using

Give an example of use. I have a Raspberry Pi4, HA. For example, event driven automation - playing "text" or script - playing a file ... / ... .mp3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.