I'm currently facing a hard problem. I need to use Pyaudio on a french windows environnement and the name of the audio devices contains é
or è
by default.
This is the error I get when a special character is present:
u=self.p.get_device_info_by_index(e)
File "C:\Python27\lib\site-packages\pyaudio.py", line 977, in get_device_info_
by_index
pa.get_device_info(device_index)
File "C:\Python27\lib\site-packages\pyaudio.py", line 987, in _make_device_inf
o_dictionary
print device_info.name
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe9 in position 13: invalid
continuation byte
This wouldn't be a problem if I could access the code (I would need to add a u"..." in front of the string chain I guess).
The problem is that I looked inside the Pyaudio code and the method causing the bug is defined in an pyd file (_portaudio.pyd), therefor, I can't modify it!
I tried to download _portaudio to compile it myself, but the distribution I found is coded in C and quite heavy (I don't know the first thing about C). Maybe I could do something there but I don't know exactly where and how.
I could also handle the problem by just commenting the line getting the name of the audio devices, but it's much harder to identify a specific audio input without its name to show to the user.
EDIT :
Here is the overall process : I call the function from pyaudio :
import pyaudio
self.p= pyaudio.PyAudio()
i=self.p.get_device_count()
for e in range(i):
u=self.p.get_device_info_by_index(e)
This will lead me into the pyaudio module which calls the method :
device_info.name
device_info being an object defined in _portaudio.pyd. Since the name of particular audio devices contain "é" or "è" (Thank you windows), and the _portaudio.pyd is not encoded to handle those characters. It returns the error :
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe9 in position 13: invalid
continuation byte