【发布时间】:2021-07-16 11:17:10
【问题描述】:
MSYS PyAudio 模块:
counter = 1
for i in range (0,self.numdevices):
if self.p.get_device_info_by_host_api_device_index(0,i).get('maxOutputChannels')>0:
self.output_devices.append([counter,i,str(self.p.get_device_info_by_host_api_device_index(0,i).get('name'))])
counter += 1
如果路径中有希腊字母,则显示不正确。
代码:
Χρήστος@Chris-pc MINGW64 /c/python/scripts/Papinhio player/src/main/python_files
$ python
Python 3.8.9 (default, Apr 13 2021, 15:54:59) [GCC 10.2.0 64 bit (AMD64)] on wi
n32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyaudio
>>> p = pyaudio.PyAudio()
>>> info = p.get_host_api_info_by_index(0)
>>> numdevices = info.get('deviceCount')
>>> for i in range(0,numdevices):
... print(p.get_device_info_by_host_api_device_index(0,i).get('name'))
...
Microsoft Sound Mapper - Input
Ìéêñüöùíï (FHD Webcam)
Microsoft Sound Mapper - Output
Ç÷åßá / ÁêïõóôéêÜ (Realtek High
>>> for i in range(0,numdevices): '))
... print(p.get_device_info_by_host_api_device_index(0,i)) )))))
...
{'index': 0, 'structVersion': 2, 'name': 'Microsoft Sound Mapper - Input', 'host
Api': 0, 'maxInputChannels': 2, 'maxOutputChannels': 0, 'defaultLowInputLatency'
: 0.09, 'defaultLowOutputLatency': 0.09, 'defaultHighInputLatency': 0.18, 'defau
ltHighOutputLatency': 0.18, 'defaultSampleRate': 44100.0}
{'index': 1, 'structVersion': 2, 'name': 'Ìéêñüöùíï (FHD Webcam)', 'hostApi': 0,
'maxInputChannels': 2, 'maxOutputChannels': 0, 'defaultLowInputLatency': 0.09,
'defaultLowOutputLatency': 0.09, 'defaultHighInputLatency': 0.18, 'defaultHighOu
tputLatency': 0.18, 'defaultSampleRate': 44100.0}
{'index': 2, 'structVersion': 2, 'name': 'Microsoft Sound Mapper - Output', 'hos
tApi': 0, 'maxInputChannels': 0, 'maxOutputChannels': 2, 'defaultLowInputLatency
': 0.09, 'defaultLowOutputLatency': 0.09, 'defaultHighInputLatency': 0.18, 'defa
ultHighOutputLatency': 0.18, 'defaultSampleRate': 44100.0}
{'index': 3, 'structVersion': 2, 'name': 'Ç÷åßá / ÁêïõóôéêÜ (Realtek High', 'hos
tApi': 0, 'maxInputChannels': 0, 'maxOutputChannels': 2, 'defaultLowInputLatency
': 0.09, 'defaultLowOutputLatency': 0.09, 'defaultHighInputLatency': 0.18, 'defa
ultHighOutputLatency': 0.18, 'defaultSampleRate': 44100.0}
【问题讨论】:
-
每个帖子一个问题。
-
好的,但我认为这是同样的问题。
-
我建议您将问题最小化,因为有 2 个不同的库:1) 验证获取字母的库是否使用正确的编码读取它,在修复该错误之后,您只需分析问题是否扩散到 Qt。也许这个问题与 Qt 无关,只是包含它会增加不必要的复杂性
-
@eyllanesc 我在问题的第二部分找到了解决方案(现在已删除):1)我设置 windows 环境变量:设置
MSYS=enable_pcon2)我在self.app.addLibraryPath(r"C:/Python/Lib/site-packages/qt5_applications/Qt/plugins/imageformats")添加 imageformats 目录(注意,上面的路径不是来自安装在msys中的python,而是来自直接安装在windows中的python 3.9,但是所有这些都不能解决pyaudio设备编码错误。 -
@eyllanesc 代码已添加。
标签: python encoding pyaudio msys