spatialaudio / python-sounddevice

:sound: Play and Record Sound with Python :snake:
https://python-sounddevice.readthedocs.io/
MIT License
982 stars 145 forks source link

Bluetooth device is not listing in sd.query_devices() #343

Open Sameer-hesta opened 3 years ago

Sameer-hesta commented 3 years ago

Hello, I am new to this, I just cloned the repo and I played one audion in the default audio device but it is not showing my Bluetooth headphones which are connected.

Here is the list of devices shown:-

Screenshot from 2021-06-30 19-28-14

bactone commented 3 years ago

I encounter the same problem, bluetooth device can't be queried. but if I use pyqt5.QMultimedia it can fetch the bluetooth audio devices

Sameer-hesta commented 3 years ago

Are you talking about https://pypi.org/project/PyQt5/ ?

if yes then will it list Bluetooth devices by sd.query_devices()
or if there is another way to list them then how can I play music on those devices?

bactone commented 3 years ago

@Sameer-hesta

  1. while, as for PyQt5 you can refer to https://www.riverbankcomputing.com/static/Docs/PyQt5/api/qtmultimedia/qtmultimedia-module.html, but the method is different, not sd.query_devices()
  2. i tried sounddevice again, and found that it can fetch my bluetooth devices with sd.query_devices(). here bellow is the result

image

so you may shall the demo code to analyze. pls don't run sd.query_devices() in the console(or you need to rerun the console after you connect to your bluetooth devices), instead, put the demo code sd.query_devices() in a .py file and run it, here bellow is an example: image

  1. how can I play music on those devices? pls refer to doc of sounddevice, https://python-sounddevice.readthedocs.io/en/0.4.1/index.html good luck

mgeier commented 3 years ago

The underlying PortAudio library currently doesn't have a "hotplug" feature, which means you have to initialize the library after you connect your bluetooth device.

If that's not possible, you can try to use sd._terminate() followed by sd._initialize(), see https://python-sounddevice.readthedocs.io/en/latest/api/expert-mode.html.

HaHeho commented 2 years ago

@Sameer-hesta did this resolve your problem? If so, feel free to close the issue.