BluetoothAudio
Sample project to echo sound on bluetooth HSP/HFP device with direct bluetooth connection.
Install / Use
/learn @Nikolay-Kha/BluetoothAudioREADME
Description
This project shows how to capture and play audio with bluetooth HSP/HFP device without pulseaudio or any other sound sy1stem, i.e. directly via bluetooth. It initialise bluetooth audio device and playback microphone data back in loop. HSP/HFP profile actually is a two connections via Bluetooth, service and audio. Service is a bluetooth RFCOMM connection which operates with AT commands. Audio connection is a bluetooth SCO connection.
Hardware
Please note that not all bluetooth adapters support HSP/HFP. For example, BCM20702 does support A2DP pefrectly, but there is no sound with HSP/HFP.
Upd: BCM20702 need proprietary firmware on Linux - http://plugable.com/2014/06/23/plugable-usb-bluetooth-adapter-solving-hfphsp-profile-issues-on-linux/
This project was tested with CSR bluetooth 4.0 USB dongle.
Usage
Turn your headset/handsfree device into advertisement mode. Run ./bluetooth_audio.py scan and wait for scan results which would be like:
[('00:12:34:56:78:F5', 'SBH-100'), ('12:33:44:55:66:4A', 'ABRC-100')]
find you device MAC address in this list. You need to do it just once. Having MAC, just run ./bluetooth_audio.py 00:12:34:56:78:F5 to run loopback sound in your device.
Also it's totally possible to import bluetooth_audio.py into your project and use BluetoothAudio class.
Specs
HFP v1.7 specs https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=292287
AT command specs http://www.3gpp.org/ftp/Specs/archive/07_series/07.07/0707-780.zip
Dependencies
sudo apt install libbluetooth-dev gcc python3-dev python3-pip
sudo pip3 install pybluez
Related Skills
node-connect
344.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
96.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
