TTS questions

First of all, did you tried with HDMI unplugged to see if audio jack is working then ?

If jack is not working, are you sure you added HA to the usergroup for vlc ?
sudo usermod -a -G audio homeassistant

Are you detecting media_player.yourspeakername in the state pannel ? if you play the tts, does the media player state switch to ‘on’ instead of idle ?

I sadly wrote out my message when I was packing up for the evening so of course I did not yet try it with the HDMI cable unplugged but I have now just tried it but it still isn’t working just yet.

I’ve definitely added HA to the vlc usergroup.

Just playing around with seeing if the media player goes off idle, will report back soon

1 Like

ok, it’s still remaining idle so the arguments must still be the issue.

Here’s what I get with apaly-l

null
Discard all samples (playback) or generate zero samples (capture)
pulse
PulseAudio Sound Server
default:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
sysdefault:CARD=ALSA
bcm2835 ALSA, bcm2835 ALSA
Default Audio Device
dmix:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Direct sample mixing device
dmix:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Direct sample mixing device
dsnoop:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Direct sample snooping device
dsnoop:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Direct sample snooping device
hw:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Direct hardware device without any conversions
hw:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Direct hardware device without any conversions
plughw:CARD=ALSA,DEV=0
bcm2835 ALSA, bcm2835 ALSA
Hardware device with all software conversions
plughw:CARD=ALSA,DEV=1
bcm2835 ALSA, bcm2835 IEC958/HDMI
Hardware device with all software conversions

can you post the declaration of media_player component in HA config and the TTS automation as well ?

Sorry, was getting kids into the bath.

media_player:
  platform: vlc
  name: pi_speaker
  arguments: '--alsa-audio-device=hw:0,0'

tts:
  platform: google

Those are my config entries

Here is an automation I’m playing with.

#Movie Night Notification
- alias: Movie Night 
  trigger:
    platform: time
    at: "18:30:00"
  condition:
    condition: and
    conditions:
    - condition: state
      entity_id: device_tracker.3ccd932b7f17
      state: home     
    - condition: time
      weekday:
        - sat
    - condition: state 
      entity_id: input_boolean.information_messages
      state: 'on'
  action:
    - service: tts.google_say
      entity_id: media_player.pi_speaker
      data:
        message: 'Hey kids, it is movie and ice cream night'

well I really can’t see where the problem is :disappointed: . To me your config is just fine, and if you install vlc properly and add HA to the usergroup, everything should run smoothly.
If you replace the tts action by a notification or some other thing that you can see (light,…) do the automation work ?

I am really confused, I did a fresh install yesterday of hassbian because my sd card got corrupted after a power outage, followed the procedure I explained here for the setup of vlc and tts, and everything is directly back to normal, without any problem.

Thanks for the feedback. At least I’m not doing something obviously wrong, it’ll most likely work somehow.

Could it possibly be the speaker itself? I’m awaiting a simple hamburger speaker arriving from ebay but in the meantime I’ve used an old CD player unit that has an AUX in? I would have thought it still would work though as it is designed to accept mp3 files and is definitely on the correct source.

Only other thing I can think of is just doing a full reboot of the pi and see what happens. Perhaps when I removed the HDMI cable I should have rebooted afterwards?

With the automations, I know they work as the mp3 files are definitely being created. In fact if I just trigger the tts function off the speaker, I see the mp3 get created but alas the media player sits idle

ok, latest update. I have my proper little speaker but still it sits idle when automations are triggered.

Perhaps removing the media player from HA and restarting and then re-installing it?

Any thoughts?

Whoa, hold on. the speaker-test -c2 -D plughw:0,0 --test=wav -w /usr/share/sounds/alsa/Front_Center.wav test works!!!

I get the front centre coming out of the speaker so that narrows things down a bit. The Pi side of things works, wohoo!

Now to see why HA has an issue

So, speaker-test -c2 -D plughw:0,1 --test=wav -w /usr/share/sounds/alsa/Front_Left.wav works as well so I changed my media player config to this

media_player:
  platform: vlc
  name: pi_speaker
  arguments: '--alsa-audio-device=plughw:0,1'

But still nothing. Would this be the right way to say it?

Could it have anything to do with my python being 3.4?

I have finally figured this out and made it work. It was to do with my SSL through Let’s Encrypt.

All I had to do was add the base URL to my http listing in the config yaml and suddenly the sound came out.

I feel like such a bloody idiot for not noticing that point in a few other threads regarding TTS.

Thanks again though for all your help as it was vital in getting this up and running.

2 Likes

Ah yes, I did not think of SSL as I only use HA in local. Thanks for the feedback, I will think about it next time :wink:

How I can call this alias? It’s possible to call him from an automation?

You can add it straight into the automation as you have it there, see mine below when I turn the last light off it says a version of goodnight, be careful he spaces are correct;

      - alias: 'Say good night'
        initial_state: on
        trigger:
          platform: state
          entity_id: switch.table_light
          to: 'off'
        action:
          service: tts.google_say
          entity_id: media_player.tts_bluetooth_speaker [or whatever your tts speaker is- I have 3]
          data_template:
            message: >-
            {{ [
            "Good night. " ,
            "Good evening. " ,
            "Sweet dreams. " ,
            "See you tomorrow. " ,
            "Have a wonderful night. " ,
            "See you soon. "
            ] |random }}'

There is also option of ‘name’ in the config platform I’m not using that in this bluetooth speaker but am on the example speaker you gave for my sound jack on the Pi;

- platform: vlc
  name: speaker_1
  arguments: '--alsa-audio-device=hw:0,0'
1 Like

Hi everybody,

I´m trying to configure my Jabra USB speakers connected to a RPI2 but I´m not getting anything. My config is something like this:

media_player:
  platform: vlc
  name: jabra
  arguments: '--alsa-audio-device=hw:CARD=USB,DEV=0'

This is the automation script to test the tts:

- alias: Lampara Sofa

  trigger:
    - platform: event
      event_type: cube_action
      event_data:
        entity_id: binary_sensor.cube_XXXXXXXXXX
        action_type: tap_twice

  action:
    - service: light.toggle
      entity_id: light.salon
    - service: tts.google_say
      entity_id: media_player.jabra
      data:
        message: 'May the Force be with you.'

The test (speaker-test -c2 -D hw:CARD=USB,DEV=0 --test=wav -w /usr/share/sounds/alsa/Front_Center.wav) works really good, but I´m not getting any success on the automation script (The light.toggle works good, but not the tts) Can anybody help me with it, please?

P.S. I have defined in base_url my URL: base_url: https://xxxx.duckdns.org

Hi,

Do you need to media_player.turn_on first before tts.google_say ? There r times on my tests that I need to like “hey google” first just to make sure its on, or turn it on from hass before firing tts.google_say

anton

TTS service has stopped working and I don’t know why… before today all was worked fine with audio.
This is my config …

http:
  api_password: ***********
  base_url: https://www.******.online:8123
  ssl_certificate: /home/****/.homeassistant/fullchain.pem
  ssl_key: /home/****/.homeassistant/privkey.pem  
media_player:
 - platform: vlc
    name: speaker_1
    arguments: '--alsa-audio-device=hw:0,0'   
tts:
  - platform: google

Tested audio output with …
cvlc --vout none LRMonoPhase4.wav
… all works good!

Tried to call tts.google_say in my config and even in the dev tools but I’ve no audio!
In the dev tools I called…
service: tts.google_say
entity: media_player.speaker_1
data: {"entity_id": "media_player.speaker_1", "message": "Hello"}
Why I’ve no audio?