Raspberry PI USB Mikrofon

    Raspberry PI USB Mikrofon

    Hi,

    Ich versuche nun schon seit mehreren Stunden ein USB Mikrofon auf dem Raspberry Pi zum laufen zu bekommen.
    Ich hab es angeschlossen und anschließend mit ​arecord -l geschaut ob es erkannt wird:

    Quellcode

    1. **** List of CAPTURE Hardware Devices ****
    2. card 1: AK5371 [AK5371], device 0: USB Audio [USB Audio]
    3. Subdevices: 1/1
    4. Subdevice #0: subdevice #0


    Anschließend wollte ich das Mikrofon über das Einstellungsfenster für Input als default hinterlegen, allerdings resettet sich die Einstellung beim schließen jedesmal.
    Habe dann rumgegoogelt und angeblich kann man das indem man die /usr/share/alsa/alsa.conf bearbeitet. Hab ich getan:

    Quellcode

    1. ​defaults.ctl.card 1
    2. defaults.pcm.card 1
    3. defaults.pcm.device 0
    4. defaults.pcm.subdevice -1
    5. defaults.pcm.nonblock 1
    6. defaults.pcm.compat 0


    Dann hab ich das minimalste Python Script zur Spracherkennung geschrieben und laufen lassen:

    Quellcode

    1. ​import speech_recognition as sr
    2. recognizer = sr.Recognizer()
    3. def listen_to_microphone():
    4. with sr.Microphone(1) as source:
    5. audio = recognizer.listen(source)
    6. return audio
    7. def try_recognize_audio(audio, language):
    8. try:
    9. return recognizer.recognize_google(audio, language=language).lower()
    10. except sr.UnknownValueError:
    11. #print("Google Speech Recognition could not understand audio")
    12. pass
    13. except sr.RequestError as e:
    14. pass
    15. while True:
    16. audio = listen_to_microphone()
    17. print(try_recognize_audio(audio, "de-DE"))


    Das Beispiel nutzt Ubeeris Speechrecognition, die unter anderem PyAudio verwendet. Beides habe ich mit pip installiert inklusive aller benötigten dependencies.
    Beim Ausführen bekommen ich diese Fehlermeldung:

    Quellcode

    1. ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
    2. ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
    3. ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.front.1:CARD=1'
    4. ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    5. ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
    6. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM front
    7. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    8. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    9. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    10. ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.surround51.1:CARD=1'
    11. ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    12. ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
    13. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround21
    14. ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.surround51.1:CARD=1'
    15. ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    16. ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
    17. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround21
    18. ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.surround40.1:CARD=1'
    19. ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    20. ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
    21. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround40
    22. ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.surround51.1:CARD=1'
    23. ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    24. ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
    25. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround41
    26. ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.surround51.1:CARD=1'
    27. ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    28. ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
    29. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround50
    30. ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.surround51.1:CARD=1'
    31. ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    32. ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
    33. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround51
    34. ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'cards.USB-Audio.pcm.surround71.1:CARD=1'
    35. ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    36. ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory
    37. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM surround71
    38. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    39. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    40. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    41. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    42. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    43. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    44. ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
    45. ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    46. ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
    47. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
    48. ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'defaults.bluealsa.device'
    49. ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    50. ALSA lib conf.c:4996:(snd_config_expand) Args evaluate error: No such file or directory
    51. ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM bluealsa
    52. ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
    53. Cannot connect to server socket err = No such file or directory
    54. Cannot connect to server request channel
    55. jack server is not running or cannot be started
    56. JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
    57. JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
    58. Expression 'parameters->channelCount <= maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1514
    59. Expression 'ValidateParameters( inputParameters, hostApi, StreamDirection_In )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2818
    60. Traceback (most recent call last):
    61. File "test.py", line 21, in <module>
    62. audio = listen_to_microphone()
    63. File "test.py", line 6, in listen_to_microphone
    64. with sr.Microphone(1) as source:
    65. File "/home/pi/.local/lib/python2.7/site-packages/speech_recognition/__init__.py", line 141, in __enter__
    66. input=True, # stream is an input stream
    67. File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 750, in open
    68. stream = Stream(self, *args, **kwargs)
    69. File "/usr/lib/python2.7/dist-packages/pyaudio.py", line 441, in __init__
    70. self._stream = pa.open(**arguments)
    71. IOError: [Errno -9998] Invalid number of channels


    Kann mir irgendjemand helfen das in Ordnung zu bringen?

    8-) faxe1008 8-)