Help me with rp3 and mediaplayer

I need help. I’m new when it comes to Linux and programming.
I have a Raspberry pi 3 and runs Hassbian image.
I have connected a speaker to the audio output on RP3 and wish HA to notify me when various lights are turned on. For example, “table lamp is turned on”. I think I must install a media player, which and how?

you might need Text-To-Speech, from google for example:

Yea, have already this in my configuration.yaml
tts:
platform: google

I think I need to have a mediaplayer or something to send the voice to. But I dont know which and how to install it…?

The VLC component works locally. The problem I found was that if two announcements are sent at once, they overlap each other and make the whole sound garbled. You just need to install the vlc package from apt-get first.

The Gstreamer component claims to do the same thing, but is broken

I have installed VLC (sudo apt-get install vlc-nox) and it seems to work… no errors.
Speaker is connected to 3,5mm output on the rp3, but no sound.

Configuration.yaml
tts:
platform: google
cache: true
cache_dir: /tmp/tts
time_memory: 300

media_player:

  • platform: vlc
    name: VLC
    arguments: ‘–alsa-audio-device=hw:1,0’

I have tried all four combinations with argumnets… still no sound

Very grateful if anyone can help me :thinking:

Anyone? :face_with_monocle:

I found a way.
My speaker won’t talk when I tried to output a TTS:

- alias: 'TTS on finished cleaning'
  #hide_entity: true
  trigger:
    platform: state
    entity_id: vacuum.cleaner_xiaomi_cleaner_robot
    from: 'on'
    to: 'off'
  action:
    service: tts.google_say
    #entity_id: media_player.living_room_home
    entity_id: media_player.speaker_1
    data:
      message: "Human, my cleaner robot had just finished cleaning."

with error message:

alsa audio output error: cannot open ALSA device "hw:1,0": No such file or directory

I think it happens because the configuration “hw:1,0” is wrong.

resolved by an easy way:
first, force rp3 to output audio from headphone, here: https://www.raspberrypi.org/documentation/configuration/audio-config.md

then, remove

arguments: ‘–alsa-audio-device=hw:1,0’

from the configuration yaml

It works for me :smiley:

1 Like

I can’t make this work :confused: tts service just download the audio file and not play through my speaker which plugged to 3.5 port on my RPi3.

I can play audio file by “vlc /tts/abc.mp3” with some errors

pi@hassbian:~ $ vlc /home/homeassistant/.homeassistant/tts/1519ae4eedc50d1cda10b6cd0e79433870382cbe_en_-_google.mp3
VLC media player 2.2.6 Umbrella (revision 2.2.6-0-g1aae78981c)
[01a412b8] pulse audio output error: PulseAudio server connection failure: Connection refused
[01a3c3a0] core interface error: no suitable interface module
[019ac940] core libvlc error: interface “globalhotkeys,none” initialization failed
[01a3c3a0] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[01a3c3a0] core interface error: no suitable interface module
[019ac940] core libvlc error: interface “dbus,none” initialization failed
[019ac940] core libvlc: Running vlc with the default interface. Use ‘cvlc’ to use vlc without interface.
[01a3c3a0] qt4 interface error: Could not connect to X server
[01a3c3a0] skins2 interface error: cannot initialize OSFactory
[01a3c3a0] [cli] lua interface: Listening on host “*console”.
VLC media player 2.2.6 Umbrella
Command Line Interface initialized. Type `help’ for help.
>