语音识别中的alsa问题(Python 3)

2024-06-07 11:35:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我的ubuntu20上有声音,我可以播放任何音频;但问题是当我使用语音识别时,alsa不能正常工作。我在windows中使用了语音识别,这很痛苦,但很有效。我已经安装了pyaudio,。。。所以这不是图书馆的问题

我已经做了:

   1.Reinstalling alsa and pulseAudio.

   2.Checking which program is using sound card.

   3.Trying to specific device to be used in Microphone().

当我使用:python -c "import pyaudio;audio=pyaudio.PyAudio();print([audio.get_device_info_by_index(i) for i in range(audio.get_device_count())])"

返回:

  ALSA lib pcm_dsnoop.c:604:(snd_pcm_dsnoop_open) unable to create IPC semaphore
  ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
  ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
  ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
  ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
  ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
  ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
  ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
  ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
  ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
  ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

  ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

  ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
  ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
  ALSA lib pcm_dsnoop.c:604:(snd_pcm_dsnoop_open) unable to create IPC semaphore

  [{'defaultSampleRate': 44100.0, 'defaultLowOutputLatency': 0.005804988662131519, 
  'defaultLowInputLatency': 0.005804988662131519, 'maxInputChannels': 2L, 'structVersion': 2L, 
  'hostApi': 0L, 'index': 0, 'defaultHighOutputLatency': 0.034829931972789115, 
  'maxOutputChannels': 2L, 'name': u'HDA Intel PCH: ALC3246 Analog (hw:0,0)', 
  'defaultHighInputLatency': 0.034829931972789115}, {'defaultSampleRate': 44100.0, 
  'defaultLowOutputLatency': 0.005804988662131519, 'defaultLowInputLatency': -1.0, 
  'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 1, 
  'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 8L, 'name': u'HDA Intel 
  PCH: HDMI 0 (hw:0,3)', 'defaultHighInputLatency': -1.0}, {'defaultSampleRate': 44100.0, 
  'defaultLowOutputLatency': 0.005804988662131519, 'defaultLowInputLatency': -1.0, 
  'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 2, 
  'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 8L, 'name': u'HDA Intel 
  PCH: HDMI 1 (hw:0,7)', 'defaultHighInputLatency': -1.0}, {'defaultSampleRate': 44100.0, 
  'defaultLowOutputLatency': 0.005804988662131519, 'defaultLowInputLatency': -1.0, 
  'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 3, 
  'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 8L, 'name': u'HDA Intel 
  PCH: HDMI 2 (hw:0,8)', 'defaultHighInputLatency': -1.0}, {'defaultSampleRate': 44100.0, 
  'defaultLowOutputLatency': 0.005804988662131519, 'defaultLowInputLatency': -1.0, 
  'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 4, 
  'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 8L, 'name': u'HDA Intel 
  PCH: HDMI 3 (hw:0,9)', 'defaultHighInputLatency': -1.0}, {'defaultSampleRate': 44100.0, 
  'defaultLowOutputLatency': 0.005804988662131519, 'defaultLowInputLatency': -1.0, 
  'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 5, 
  'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 8L, 'name': u'HDA Intel 
  PCH: HDMI 4 (hw:0,10)', 'defaultHighInputLatency': -1.0}, {'defaultSampleRate': 48000.0, 
  'defaultLowOutputLatency': 0.021333333333333333, 'defaultLowInputLatency': -1.0, 
  'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 6, 
  'defaultHighOutputLatency': 0.021333333333333333, 'maxOutputChannels': 128L, 'name': 
  u'sysdefault', 'defaultHighInputLatency': -1.0}, {'defaultSampleRate': 44100.0, 
  'defaultLowOutputLatency': 0.005804988662131519, 'defaultLowInputLatency': -1.0, 
  'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 7, 
  'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 2L, 'name': 
  u'front', 'defaultHighInputLatency': -1.0}, {'defaultSampleRate': 44100.0, 
  'defaultLowOutputLatency': 0.005804988662131519, 'defaultLowInputLatency': -1.0, 
  'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 8, 
  'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 2L, 'name': 
  u'surround40', 'defaultHighInputLatency': -1.0}, {'defaultSampleRate': 44100.0, 
  'defaultLowOutputLatency': 0.005804988662131519, 'defaultLowInputLatency': -1.0, 
  'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 9, 
  'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 2L, 'name': 
  u'surround51', 'defaultHighInputLatency': -1.0}, {'defaultSampleRate': 44100.0, 
  'defaultLowOutputLatency': 0.005804988662131519, 'defaultLowInputLatency': -1.0, 
  'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 10, 
  'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 2L, 'name': 
  u'surround71', 'defaultHighInputLatency': -1.0}, {'defaultSampleRate': 44100.0, 
  'defaultLowOutputLatency': 0.005804988662131519, 'defaultLowInputLatency': -1.0, 
  'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 11, 
  'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 8L, 'name': 
  u'hdmi', 'defaultHighInputLatency': -1.0}, {'defaultSampleRate': 44100.0, 
  'defaultLowOutputLatency': 0.007755102040816327, 'defaultLowInputLatency': 
  0.007755102040816327, 'maxInputChannels': 128L, 'structVersion': 2L, 'hostApi': 0L, 
  'index': 12, 'defaultHighOutputLatency': 0.023219954648526078, 'maxOutputChannels': 128L, 
  'name': u'samplerate', 'defaultHighInputLatency': 0.023219954648526078}, 
  {'defaultSampleRate': 44100.0, 'defaultLowOutputLatency': 0.007755102040816327, 
  'defaultLowInputLatency': 0.007755102040816327, 'maxInputChannels': 128L, 'structVersion': 
  2L, 'hostApi': 0L, 'index': 13, 'defaultHighOutputLatency': 0.023219954648526078, 
  'maxOutputChannels': 128L, 'name': u'speexrate', 'defaultHighInputLatency': 
  0.023219954648526078}, {'defaultSampleRate': 44100.0, 'defaultLowOutputLatency': 
  0.005804988662131519, 'defaultLowInputLatency': 0.005804988662131519, 'maxInputChannels': 
  8L, 'structVersion': 2L, 'hostApi': 0L, 'index': 14, 'defaultHighOutputLatency': 
  0.034829931972789115, 'maxOutputChannels': 8L, 'name': u'upmix', 
  'defaultHighInputLatency': 0.034829931972789115}, {'defaultSampleRate': 44100.0, 
  'defaultLowOutputLatency': 0.005804988662131519, 'defaultLowInputLatency': 
  0.005804988662131519, 'maxInputChannels': 6L, 'structVersion': 2L, 'hostApi': 0L, 'index': 
  15, 'defaultHighOutputLatency': 0.034829931972789115, 'maxOutputChannels': 6L, 'name': 
  u'vdownmix', 'defaultHighInputLatency': 0.034829931972789115}, {'defaultSampleRate': 
  48000.0, 'defaultLowOutputLatency': 0.021333333333333333, 'defaultLowInputLatency': -1.0, 
  'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 16, 
  'defaultHighOutputLatency': 0.021333333333333333, 'maxOutputChannels': 128L, 'name': 
  u'default', 'defaultHighInputLatency': -1.0}, {'defaultSampleRate': 48000.0, 
  'defaultLowOutputLatency': 0.021333333333333333, 'defaultLowInputLatency': -1.0, 
  'maxInputChannels': 0L, 'structVersion': 2L, 'hostApi': 0L, 'index': 17, ' 
  defaultHighOutputLatency': 0.021333333333333333, 'maxOutputChannels': 2L, 'name': u'dmix', 
  'defaultHighInputLatency': -1.0}]

错误:

 ALSA lib pcm_dsnoop.c:604:(snd_pcm_dsnoop_open) unable to create IPC semaphore
 ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
 ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
 ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
 ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
 ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
 ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
 ALSA lib pcm_route.c:869:(find_matching_chmap) Found no matching channel map
 ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
 ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
 ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused

 

我使用的是VS代码,这可能是一个bug。问题是我怎样才能摆脱它


Tags: nameindexlibalsapcmmatchingdefaulthighinputlatencystructversion
1条回答
网友
1楼 · 发布于 2024-06-07 11:35:08

嘿,伙计们,我用sudo apt-get install pavucontrol安装了voice control。在Thermanal中使用pavucontrol运行它。在语音控制中,将录音设备置于0。我的笔记本电脑内置了麦克风,我知道如何找到它

相关问题 更多 >

    热门问题