TTS update

alexa is capable of notifcations but not with the native service.

Hi, did you ever solve this issue with the template? I have the same but can’t find a solution.

@Tyfoon i just installed vlc and that solve my problem.

Hi hokagegano,

just a newbie question: I’m trying to let my HA on RPi to play audio from the same RPi on which it’s running. Is it possible via the PulseAudio? I was playing with MPD (but cannit play MP3 files), and cmus (I was unable to set it up).

Thanx for help!
PS: latest HA running on RPi via VENV.

If you want play some mp3 on rpi, you can install omxplayer.

hi maximkrusina,

Yes on my side, i have a pine 64 (sort of raspberry pi) which runs Home assistant with speaker installed on it.
I use pulseaudio (you need to grant home assistant user to work with pulseaudio if not enabled by default).
I use VLC installed on the pine64 to use TTS. vlc-nox works fine with home-assistant and mp3.

Can you give more details on how to grant home assistant user to work with pulseaudio or vlc, my tts mp3 is generated and is playable manually but no sound through hass, so I suspect something to do with permssison.

1 Like

My previous post :slight_smile:

Hi,

My problem was the user running hass-daemon (root) was unable to run audio on soundcard.
So i had to configure pulseaudio to do that

addgroup --system pulse
adduser --system --ingroup pulse --home /var/run/pulse pulse
addgroup --system pulse-access
adduser pulse audio
adduser root pulse-access

if already is fine you need to do that as root
pulseaudio -D --system

now you can test the mp3 generated
cd /tmp/tts
vlc generated.mp3

if it works now you need to execute pulseaudio -D --system at startup.

I modifiy /etc/init.d/hass-daemon with that:
start() {
if [ -f $PID_FILE ] && kill -0 $(cat $PID_FILE) 2> /dev/null; then
echo ‘Service already running’ >&2
return 1
fi
echo ‘Starting service…’ >&2
local CMD="$PRE_EXEC hass $FLAGS $REDIRECT;"
su -c “$CMD” $RUN_AS
echo ‘Service started’ >&2
su -c “pulseaudio -D --system” $RUN_AS
}

it’s so dirty because if i restart hass, pulseaudio -D --system is already active, but it’s not a big deal.

Oh, just realsized that post was you, I hesitated to do it as its a bit dirty, I was thinking someone might get a better way, hahaha, hopefully the future version will fix this issue.

Should never run anything as root… first problem.

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 :slight_smile:

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.

1 Like

@hareeshmu that support PT language?

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…

1 Like