gpt4 book ai didi

python - alsaaudio python卡要放什么?

转载 作者:行者123 更新时间:2023-12-01 02:41:58 24 4
gpt4 key购买 nike

我正在尝试在我的 python 代码中使用 alsaaudio。

inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE, alsaaudio.PCM_NONBLOCK, 卡)

第三个参数card应该放什么?

root@abc:~/Desktop# arecord --list-devices
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC269VB Analog [ALC269VB Analog]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 1: H340 [Logitech USB Headset H340], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0

我想从 Logitech USB 耳机输入音频。
应该是 hw:1,0 ??????

谢谢

最佳答案

documentation说:

class alsaaudio.PCM(type=PCM_PLAYBACK, mode=PCM_NORMAL, device='default', cardindex=-1)

This class is used to represent a PCM device (either for playback and recording). The arguments are:
[…]

  • device - the name of the PCM device that should be used (for example a value from the output of pcms()). The default value is 'default'.

[…]

Changed in 0.8:

  • The card keyword argument is still supported, but deprecated. Please use device instead.
  • The keyword argument cardindex was added.

The card keyword is deprecated because it guesses the real ALSA name of the card. This was always fragile and broke some legitimate usecases.

关于python - alsaaudio python卡要放什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45601034/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com