1

この YouTube ビデオ ( https://www.youtube.com/watch?v=AGatX_8gaeM ) を参考にして、仮想アシスタント プログラムの作成を開始しました。基本的な音声認識コードを作成しましたが、内部マイクと外部マイクの両方への音声入力に応答しません。プログラムを実行すると

import speech_recognition as sr
from gtts import gTTS

def recordAudio():
   record=sr.Recognizer()

   with sr.Microphone() as source:
      print('Say something!')
      audio=record.listen(source)

   data=''

   try:
      data=record.recognize_google(audio)
      print('You said: {}'.format(data))

   except sr.UnknownValueError:
      print('Ran into some unknown error retry....')
      recordAudio()

   except sr.RequestError:
      print('Ran into request error retry....')
      recordAudio()

   except:
      print('Ran into something other than UnknownValueError or RequestError')


recordAudio()

しかし、これは起こります:

ALSA lib pcm_dsnoop.c:641:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
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_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 pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback
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_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
Say something!

そして、コマンド

import speech_recognitioin as sr
sr.Microphone.list_microphone_names()

これを返します:

ALSA lib pcm_dsnoop.c:641:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
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_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 pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback
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_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave
['HD-Audio Generic: HDMI 0 (hw:0,3)', 'HD-Audio Generic: ALC236 Analog (hw:1,0)', 'hdmi', 
'pulse', 'default']

誰かがこれで私を助けてくれますか。

4

2 に答える 2