0

I am working on a Python script that lets Raspberry Pi 4 play audio announcements (mp3 format) at specified times. I am using the Python OS library to send the play audio commands to system.

The aplay -l command gives the list of the available audio devices, mine shows HDMI and analog (does not show Bluetooth speakers).

Then I pick the one I want (analog in my case), and specify the output this way:

AUDIODEV=hw:0,0 play audio.mp3

The question is: is there a way to send output to the paired Bluetooth speaker? I do not want to change the default audio device to Bluetooth. Ideally, I want the default to still be HDMI but only send these commands to Bluetooth speaker.

Any suggestions on how to achieve that?

Greenonline
  • 2,969
  • 5
  • 27
  • 38
Bahi8482
  • 111
  • 1
  • 4

1 Answers1

1

This worked for me:

sox -v 1.5 example.mp3 -t pulseaudio bluez_sink.00_00_00_00_00_00.a2dp_sink #this will play the file into the bluetooth speaker (replace the name after pulseaudio with the output from 'pacmd list-sinks | grep -e 'name:' -e 'index' -e 'Speakers' ).

These steps worked for me to connect pi (zero and 4) with BT speaker: https://gist.github.com/actuino/9548329d1bba6663a63886067af5e4cb#pair-and-connect

Bahi8482
  • 111
  • 1
  • 4