TTS on Bluetooth speaker via Raspberry Pi

AH! … the pulse is not running as service :stuck_out_tongue:

ok … i started the pulse audio as servie nw… let me check dev… as with player i don’t hearanything and it plays just randonly…

Can you run the following command?

pactl list short | grep bluez

What is the output? If your Bluetooth speaker is paired and available to Pulse Audio, it should appear as a sink in the output.

hass@home-assistant:/home/pi/appdaemon_dashboard/appdaemon/logs$  pactl list short | grep bluez
12      module-bluez5-discover
13      module-bluez4-discover
14      module-bluez5-device    path=/org/bluez/hci0/dev_FC_A8_9A_6F_3E_77
1       bluez_card.FC_A8_9A_6F_3E_77    module-bluez5-device.c

@pkozul awesome work. I did your floorplan also amazing there too. I have followed your steps and tested the help you have given in the post. My media.player_bluetooth_speaker shows up as off. I cant figure out how to change it to on. I have it showing up on a card I do not have the ability to turn it on or off. Any suggestions?

Hi @Charles_Brown Not sure about the on/off states for the Bluetooth speaker. Did you get it to play any TTS?

Same problem here, shows off, the connection is active (i can see the blue light on my soundsticks, yet no sound is coming on)

Because this is a ‘work in progress’ custom component, I don’t believe it actually supports getting the real state from the actual Bluetooth speaker. All it really does is support the ‘media play’ action, that is, it forwards the TTS content (i.e. MP3 URL) to a script, which then downloads the file, and uses Pulse Audio and mplayer to play it.

I can see in the logs the url that is created. I can copy the url and paste it in the url and it will

play

Can you type the following command? What is the output? It should show your Bluetooth device as a sink (something like bluez_card.FC_A8_9A_6F_3E_77).

pactl list short | grep bluez

That’s a good starting point to first see whether your speaker is actually paired and connected to your Raspberry Pi.

I wonder if this has something to do with it

The
state_off, part

pi@raspberrypi:~ $ ps aux | grep pulse pulse 440 0.0 0.8 100156 8096 ? S<sl Jul09 0:00 /usr/bin/pulseaudio --system --disallow-exit --disable-shm --exit-idle-time=-1 pi 9288 0.0 0.2 4280 2008 pts/1 S+ 00:04 0:00 grep --color=auto pulse pi@raspberrypi:~ $ pactl list short | grep bluez 11 module-bluez5-discover 13 module-bluez5-device path=/org/bluez/hci0/dev_88_C6_26_AC_41_1F 2 bluez_sink.88_C6_26_AC_41_1F module-bluez5-device.c s16le 2ch 44100Hz SUSPENDED 2 bluez_sink.88_C6_26_AC_41_1F.monitor module-bluez5-device.c s16le 2ch 44100Hz SUSPENDED 2 bluez_card.88_C6_26_AC_41_1F module-bluez5-device.c

OK, that looks OK. Can you try playing an MP3 file? Make sure to replace [some_mp3_file] with a real MP3 file name.

mplayer -ao pulse::bluez_sink.88_C6_26_AC_41_1F -volume 50 [some_mp3_file]

That should give you some sound coming out of your Bluetooth speaker.

Any special place to put the mp3?
never done this before lol

I wouldn’t worry about the ‘on’ or ‘off’ state, as these states don’t get used. In my case, it’s the same:

The state doesn’t get used at all. I guess I should have hard-coded it to ‘on’ :slight_smile:

Maybe, if I get some time, I will look at keeping the state in sync with the actual ‘real connection’ of the device.

``

Creating config file: /home/pi/.mplayer/config
MPlayer2 2.0-728-g2c378c7-4+b1 (C) 2000-2012 MPlayer Team
Cannot open file ‘/home/pi/.mplayer/input.conf’: No such file or directory
Failed to open /home/pi/.mplayer/input.conf.
Cannot open file ‘/etc/mplayer/input.conf’: No such file or directory
Failed to open /etc/mplayer/input.conf.

``

``
pi@raspberrypi:~ $ mplayer -ao pulse::bluez_sink.88_C6_26_AC_41_1F -volume 25 /tmp/katyusha.mp3
MPlayer2 2.0-728-g2c378c7-4+b1 © 2000-2012 MPlayer Team

Playing /tmp/katyusha.mp3.
Failed to recognize file format.

``

Oops… my bad… can you grab this file?

 wget http://www.sample-videos.com/audio/mp3/crowd-cheering.mp3 -O /tmp/crowd.mp3

And then

mplayer -ao pulse::bluez_sink.88_C6_26_AC_41_1F -volume 50  /tmp/crowd.mp3

ok i did hear crowd and horns

Great… so at least we know the Bluetooth speaker works with your Pi using Pulse Audio / mplayer.

Can you paste your HA config for the bluetooth speaker?