spatialaudio / python-sounddevice

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

设备解码错误?utf-8' codec can't decode byte 0xc2 in position 6: invalid continuation byte #511

Closed kkvrry closed 5 months ago

kkvrry commented 6 months ago
>>> print(sounddevice.query_devices())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\ai\Retrieval-based-Voice-Conversion-WebUI\venv\lib\site-packages\sounddevice.py", line 564, in query_devices
    return DeviceList(query_devices(i)
  File "D:\ai\Retrieval-based-Voice-Conversion-WebUI\venv\lib\site-packages\sounddevice.py", line 564, in <genexpr>
    return DeviceList(query_devices(i)
  File "D:\ai\Retrieval-based-Voice-Conversion-WebUI\venv\lib\site-packages\sounddevice.py", line 578, in query_devices
    name = name_bytes.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc2 in position 6: invalid continuation byte

是我的设备名比较特殊吗?不太懂哎

mgeier commented 6 months ago

This sounds similar to #490.

Do you happen to know the host API of the problematic device? Is it ASIO?

If yes, can you please check if #512 fixes the issue?

kkvrry commented 6 months ago

我不太懂您说的,但是昨天晚上解决了,devices解码方式换成unicode_escape后成功了

kkvrry commented 6 months ago

ok,懂了,是新提交的代码么?我今天去试试

mgeier commented 6 months ago

Yes, #512 is new code that I submitted. You can try it out with a development installation as described here: https://python-sounddevice.readthedocs.io/en/0.4.6/CONTRIBUTING.html#development-installation

If you use unicode_escape for decoding, the error should go away, but the device name will contain escaped characters and will not be human readable, right?