Thanx guys, I’ll try VLC + pulseausio…
Just - do I need to install both? I need only something which will work with TTS
Atm I can play mp3s using VLC over the command line, but not with HA (TTS). TTS is working however with my chromecasts. I did install HA using the Hassbian image (https://home-assistant.io/getting-started/installation-raspberry-pi-image/) with user homeassistant.
Should I give homeassistant access to pulseaudio to get it working?
addgroup --system pulse
adduser --system --ingroup pulse --home /var/run/pulse pulse
addgroup --system pulse-access
adduser pulse audio
adduser homeassistant pulse-access
Hi,
Yes my problem was here.
After giving rights to user from pulseaudio everything works fine !
Doesn’t work here… got my VLC broken now, can’t play sounds anymore (only some white noise). Thanks for helping anyway! Some work to do this weekend:)
I had created a custom TTS solution sometime back as the TTS was not available on early releases of HA.
I am using PicoTTS, which is one of the good offline TTS engine I came across so far.
Here is the demo: View Demo
In the demo, the TTS is for the motion detection sensor. (My custom Microwave Radar Sensor using MySensors node)
I’m happy to share the details if anyone interested
Also see my Grandfather Clock Chime implementation Here
I have tried Pico using this guide but the sound is too muffled or too much bass. Google TTS sounds much clearer and natural. But honestly I prefer something that works offline and independent from a 3rd party provider. Unfortunately, Google TTS is the best option for me right now. Do you have any other suggestion for offline TTS that is comparable to Google?
I had similar issue with sound using Pulse audio. Alsa works fine for me.
Here is some info about PicoTTS if any one interested.
Here is the demo: View Demo
Installing PicoTTS
sudo su
cd /
wget http://incrediblepbx.com/picotts-raspi.tar.gz
tar zxvf picotts-raspi.tar.gz
rm -f picotts-raspi.tar.gz
cd /root
./picotts-install.sh
Testing PicoTTS
pico2wave --wave sample.wav -l en-US "Here is a sample, using the PICO text to speech engine."
aplay sample.wav
Below is the Shell script will take the “Text” as argument to speech conversion
Shell Command File: TTS_Play.sh
#!/bin/bash
pico2wave -w /tmp/omx.wav "$1"
#below line just to play chime sound to gather attention
aplay -Dplughw:CARD=ALSA,DEV=0 /home/homeassistant/.homeassistant/chime.wav
aplay -Dplughw:CARD=ALSA,DEV=0 /tmp/omx.wav
HA Configuration yaml:
input_boolean:
motion_livingroom_override:
initial: on
shell_command:
ttsplay: '/home/homeassistant/.homeassistant/TTS_Play.sh "Hareesh, You have a visitor!"'
automation 2:
- alias: Alert Motion
trigger:
platform: state
entity_id: binary_sensor.motion_sensor_3_1
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_boolean.motion_livingroom_override
state: 'on'
action:
- service: notify.myhtml5
data:
message: 'Motion Deteted at Main Gate!!'
title: 'Home Assistant Alert'
- service: shell_command.ttsplay
We can configure the shell_command section with what ever text we need to send to the TTS engine.
I’m not sure on PT language is available or not. We have to give it a try.
I just found a post on building it from sources.
http://rpihome.blogspot.in/2015/02/installing-pico-tts.html?m=1
It says…pico tts (at least on debian systems) can use just german, english, french
, italian and spanish. Maybe you could try to look at the sources of the software to see if there’s a way to add new voices, but I think it would not be an easy task…
I have a base_url that’s behind Let’s Encrypt SSL and the URL is in the config but Sonos is saying connection was lost…
Thoughts?
as an update, going to https://baseurl.example.com/api/tts_proxy/filenameincachefolder.mp3
does work in the browser.
Looks like I didn’t need the base_url. Got it working.
I have your example working when I run it as the “pi” user. However when I run it as the “hass” user I get the following error: “X11 connection rejected because of wrong authentication.” looks like I need to grant some permissions to hass. Any suggestions on how I might do this?
Try the chmod
755 or 777 to the specified file. Make sure the user ‘hass’ added to the audio group.
sudo usermod -a -G groupName userName
sudo usermod -a -G audio hass
Got it working now! Thanks guys! Now I am trying to get some random output to TTS, like described here for Alexa. However, when I use
service: tts.google_say
data_template:
entity_id: media_player.speaker
message: '{{ ["Hi" , "Bye" ] | random }}'
TTS always plays the first ‘Hi’, and never the second ‘Bye’. Any ideas?
I have 36.1 All in One Installer. I have applied the permissions above. When I call the google_say service as posted at the top of this page, the file is recorded and saved but no sound comes out of my attached speakers (3.5mm jack). I have applied permissions for audio as described in this post.
I can play sound via command line with either aplay, omxplayer or vlc.
I am getting a play_media not implemented error. I also receive this error if I use picotts_say. I am not sure what else to do here
17-01-28 13:36:13 homeassistant.core: Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/usr/lib/python3.4/asyncio/tasks.py”, line 233, in _step
result = coro.throw(exc)
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py”, line 1054, in _event_to_service_call
yield from service_handler.func(service_call)
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/media_player/init.py”, line 364, in async_service_handler
yield from getattr(player, method[‘method’])(**params)
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/tasks.py”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/media_player/init.py”, line 644, in play_media
raise NotImplementedError()
NotImplementedError
I have the same problem with Onkyo media_player. My ownership is updated and permissions …
but, I keep getting this task exception as well!
MaryTTS?
I would love to see support for this, if I do I may have a public server for you guys to use!.
hello i have this configuration:
media_player:
platform: vlc
name: VLC
tts:
platform: google
cache: true
cache_dir: /tmp/tts
time_memory: 300
but when i updated to new version of HA i dont ear any sound on my speaker, i have it connected directly on rpi. that is my log:
17-02-19 00:59:18 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=3050450192-2>
17-02-19 00:59:18 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 2768997136: Sending {'type': 'event', 'event': {'data': {'entity_id': 'media_player.vlc', 'old_state': <state media_player.vlc=idle; media_position_updated_at=2017-02-19T00:57:28.716104+00:00, volume_level=1.0, media_content_type=music, supported_features=16909, is_volume_muted=False, friendly_name=VLC, media_duration=-0.001, media_position=0.001 @ 2017-02-19T00:57:28.731515+00:00>, 'new_state': <state media_player.vlc=idle; media_position_updated_at=2017-02-19T00:59:17.932650+00:00, volume_level=1.0, media_content_type=music, supported_features=16909, is_volume_muted=False, friendly_name=VLC, media_duration=0.0, media_position=0.0 @ 2017-02-19T00:57:28.731515+00:00>}, 'time_fired': datetime.datetime(2017, 2, 19, 0, 59, 17, 973688, tzinfo=<UTC>), 'origin': 'LOCAL', 'event_type': 'state_changed'}, 'id': 2}
17-02-19 00:59:18 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=3050450192-1>
17-02-19 00:59:18 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=media_player.vlc, new_state=<state media_player.vlc=playing; media_position_updated_at=2017-02-19T00:59:17.932650+00:00, volume_level=1.0, media_content_type=music, supported_features=16909, is_volume_muted=False, friendly_name=VLC, media_duration=0.0, media_position=0.0 @ 2017-02-19T00:59:18.808062+00:00>, old_state=<state media_player.vlc=idle; media_position_updated_at=2017-02-19T00:59:17.932650+00:00, volume_level=1.0, media_content_type=music, supported_features=16909, is_volume_muted=False, friendly_name=VLC, media_duration=0.0, media_position=0.0 @ 2017-02-19T00:57:28.731515+00:00>>
17-02-19 00:59:18 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 2768997136: Sending {'type': 'event', 'event': {'data': {'entity_id': 'media_player.vlc', 'old_state': <state media_player.vlc=idle; media_position_updated_at=2017-02-19T00:59:17.932650+00:00, volume_level=1.0, media_content_type=music, supported_features=16909, is_volume_muted=False, friendly_name=VLC, media_duration=0.0, media_position=0.0 @ 2017-02-19T00:57:28.731515+00:00>, 'new_state': <state media_player.vlc=playing; media_position_updated_at=2017-02-19T00:59:17.932650+00:00, volume_level=1.0, media_content_type=music, supported_features=16909, is_volume_muted=False, friendly_name=VLC, media_duration=0.0, media_position=0.0 @ 2017-02-19T00:59:18.808062+00:00>}, 'time_fired': datetime.datetime(2017, 2, 19, 0, 59, 18, 822724, tzinfo=<UTC>), 'origin': 'LOCAL', 'event_type': 'state_changed'}, 'id': 2}
17-02-19 00:59:18 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=media_player.vlc, new_state=<state media_player.vlc=idle; media_position_updated_at=2017-02-19T00:59:17.932650+00:00, volume_level=1.0, media_content_type=music, supported_features=16909, is_volume_muted=False, friendly_name=VLC, media_duration=0.0, media_position=0.0 @ 2017-02-19T00:59:18.955642+00:00>, old_state=<state media_player.vlc=playing; media_position_updated_at=2017-02-19T00:59:17.932650+00:00, volume_level=1.0, media_content_type=music, supported_features=16909, is_volume_muted=False, friendly_name=VLC, media_duration=0.0, media_position=0.0 @ 2017-02-19T00:59:18.808062+00:00>>
17-02-19 00:59:18 INFO (MainThread) [homeassistant.core] Bus:Handling <Event service_executed[L]: service_call_id=3050450192-4>
17-02-19 00:59:19 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 2768997136: Sending {'type': 'event', 'event': {'data': {'entity_id': 'media_player.vlc', 'old_state': <state media_player.vlc=playing; media_position_updated_at=2017-02-19T00:59:17.932650+00:00, volume_level=1.0, media_content_type=music, supported_features=16909, is_volume_muted=False, friendly_name=VLC, media_duration=0.0, media_position=0.0 @ 2017-02-19T00:59:18.808062+00:00>, 'new_state': <state media_player.vlc=idle; media_position_updated_at=2017-02-19T00:59:17.932650+00:00, volume_level=1.0, media_content_type=music, supported_features=16909, is_volume_muted=False, friendly_name=VLC, media_duration=0.0, media_position=0.0 @ 2017-02-19T00:59:18.955642+00:00>}, 'time_fired': datetime.datetime(2017, 2, 19, 0, 59, 18, 956290, tzinfo=<UTC>), 'origin': 'LOCAL', 'event_type': 'state_changed'}, 'id': 2}
17-02-19 00:59:19 INFO (MainThread) [homeassistant.components.http] Serving /api/tts_proxy/2e6f9b0d5885b6010f9167787445617f553a735f_en_-_google.mp3 to 192.168.1.89 (auth: False)
i am running hassbian toybox.