Score:1

Speech recognition module alsa error

cn flag

I am trying to convert speech to text using SpeechRecognition on ubuntu 21.10


Here is the code
import speech_recognition as sr

def listen():
    r = sr.Recognizer()
    mic = sr.Microphone(device_index=1)
    with mic as source:
        audio = r.listen(source, timeout=10)
        return r.recognize_google(audio)
print(listen())

This is throwing an error

ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:877:(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 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
Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1514
Expression 'ValidateParameters( inputParameters, hostApi, StreamDirection_In )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2818
Traceback (most recent call last):
  File "/home/harsha/PycharmProjects/playground/audio.py", line 29, in <module>
    assitant.listen()
  File "/home/harsha/PycharmProjects/playground/audio.py", line 23, in listen
    with mic as source:
  File "/home/harsha/PycharmProjects/playground/sand/lib/python3.9/site-packages/speech_recognition/__init__.py", line 138, in __enter__
    self.audio.open(
  File "/home/harsha/PycharmProjects/playground/sand/lib/python3.9/site-packages/pyaudio.py", line 750, in open
    stream = Stream(self, *args, **kwargs)
  File "/home/harsha/PycharmProjects/playground/sand/lib/python3.9/site-packages/pyaudio.py", line 441, in __init__
    self._stream = pa.open(**arguments)
OSError: [Errno -9998] Invalid number of channels

I am doing this in my laptop with inbuilt microphone.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.