lorenz
lorenz

Reputation: 208

record audio from bluetooth headset using bluealsa on Linux

I am using onboard Bluetooth on Raspberry pi zero and connected a Bluetooth speaker which also has a mic. I want to record audio from this BT speaker mic.

I understand bluealsa command line can be used for this purpose, and also for playback of a .wav audio file.

I could not succeed with bluealsa sco profile to record audio. (OS: Dietpi) The device is able to connect to pi, and can play wav files, using: aplay -D bluealsa:DEV=XX:XX:XX:XX:XX:XX,PROFILE=a2dp sample.wav

However, with arecord, it says its recording, but doesn't record anything, also it doesn't throw any error.

using: arecord -f cd -D bluealsa:DEV=XX:XX:XX:XX:XX:XX,PROFILE=sco test.wav

Output: Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

test.wav shows only 44 bytes on the system:

-rw-r--r-- 1 root root 44 Jun 9 15:38 test.wav

when I try to play the recorded file, its just noise.

Could anyone help? Is recording from BTspeakers even supported in bluealsa package itself?

Upvotes: 3

Views: 4048

Answers (1)

lorenz
lorenz

Reputation: 208

Like I said, after a lot of head scratching, found some key aspects are missing while bluealsa service is getting started.

  1. By default, the bluealsa service is starting with only with "a2dp-source" profile. This is only for playback of audio. But for recording audio, it needs "a2dp-sink", "hfp-ag", and "hsp-ag" profiles.

  2. Use below command if you are using any raspberry or ubuntu based distributions. "systemctl cat bluealsa" This shows the unit file for "bluealsa" service. it should have the below line for ExecStart. ExecStart=/usr/bin/bluealsa -p a2dp-sink -p a2dp-source -p hfp-ag -p hsp-ag

3.Usually what I have observed is with out any -p options passed to it. change the unit file and restart the service. Note: whenever any systemctl unit files are changed, the below command must be executed to take changes into effect.

1. "systemctl daemon-reload"
2. systemctl restart bluealsa

4.Another thing to note is: using profile "sco" in asounrc file.

recording audio should work after these changes! This is what worked for me! after a long ordeal!

Upvotes: 2

Related Questions