Reputation: 51
I am trying to get the audio devices names from using PyQt4 framework in Python.
The code is as follows:
from PyQt4 import QtCore, QtGui, QtMultimedia
temp_list=()
x=()
for i in range(5):
temp_list=QtMultimedia.QAudioDeviceInfo.availableDevices(QtMultimedia.QAudio.AudioInput)
x=QtMultimedia.QAudioDeviceInfo.deviceName
print temp_list
print x
yet somehow I can't get the device names. Not too sure how to proceed from here.
Upvotes: 1
Views: 2315
Reputation: 76
Just another way of doing it also, sounddevice lib is nice and easy to use !
py -m pip install sounddevice
import sounddevice as sd
def query():
a = sd.query_devices()
print(a)
query()
Upvotes: 1
Reputation: 120608
It seems from your example code that you don't have much experience of using Python. I would advise you to work through some tutorials before proceeding any further. The Beginners Guide on the Python wiki is a good place to start.
I would also advise you to make full use of Python's interactive mode when trying to work out how the Qt APIs work. With the use of print
, you can answer basic questions very quickly and easily. Here's an example session:
Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:18:40) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt4 import QtMultimedia
>>> devices = QtMultimedia.QAudioDeviceInfo.availableDevices(QtMultimedia.QAudio.AudioInput)
>>> print(devices)
[<PyQt4.QtMultimedia.QAudioDeviceInfo object at 0x00CC5C30>, <PyQt4.QtMultimedia.QAudioDeviceInfo object at 0x00CC5C70>]
>>> for device in devices:
... print(device.deviceName())
...
Intel(r) Integrated Audio
default
Upvotes: 4