简体   繁体   English

在 Raspberry Pi 零 2 W 问题上使用蓝牙耳机中的麦克风

[英]Using Microphone from Bluetooth headset on Raspberry Pi Zero 2 W Issue

So when I connect the Bluetooth headset to the Zero 2 W the audio works, but whenever I attempt to select it as an audio input while being an audio output as well, it appears to work but when I run my Python code that uses the microphone it results in the following messages:因此,当我将蓝牙耳机连接到 Zero 2 W 时,音频可以正常工作,但是每当我尝试将 select 作为音频输入同时也是音频 output 时,它似乎可以正常工作,但是当我运行使用麦克风的 Python 代码时它会产生以下消息:

ALSA lib pcm_plug.c:928:(snd_pcm_plug_hw_refine_cchange) Format: S16_LE
ALSA lib pcm_plug.c:933:(snd_pcm_plug_hw_refine_cchange) Slave format: IEC958_SUBFRAME_LE
ALSA lib pcm_plug.c:835:(snd_pcm_plug_hw_refine_schange) Unable to find an usable slave format for 'plug:hw'
ALSA lib pcm_plug.c:839:(snd_pcm_plug_hw_refine_schange) Format: S16_LE
ALSA lib pcm_plug.c:844:(snd_pcm_plug_hw_refine_schange) Slave format: IEC958_SUBFRAME_LE
ALSA lib pcm_plug.c:924:(snd_pcm_plug_hw_refine_cchange) Unable to find an usable client format
ALSA lib pcm_plug.c:928:(snd_pcm_plug_hw_refine_cchange) Format: S16_LE
ALSA lib pcm_plug.c:933:(snd_pcm_plug_hw_refine_cchange) Slave format: IEC958_SUBFRAME_LE
ALSA lib pcm_plug.c:835:(snd_pcm_plug_hw_refine_schange) Unable to find an usable slave format for 'plug:hw'
ALSA lib pcm_plug.c:839:(snd_pcm_plug_hw_refine_schange) Format: S16_LE
ALSA lib pcm_plug.c:844:(snd_pcm_plug_hw_refine_schange) Slave format: IEC958_SUBFRAME_LE
ALSA lib pcm_plug.c:924:(snd_pcm_plug_hw_refine_cchange) Unable to find an usable client format
ALSA lib pcm_plug.c:933:(snd_pcm_plug_hw_refine_cchange) Slave format: IEC958_SUBFRAME_LE
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_direct.c:1206:(snd1_pcm_direct_initialize_slave) requested or auto-format is not available
ALSA lib pcm_dmix.c:1087:(snd_pcm_dmix_open) unable to initialize slave

Here is my code:这是我的代码:

with sr.Microphone() as source:
    r.adjust_for_ambient_noise(source, duration=0.2)
    while 1:
        try:
            audio = r.listen(source, phrase_time_limit=15, timeout=0.9)
        except sr.WaitTimeoutError:
            continue
        try:
            speech = r.recognize_google(audio)
        except:
            continue
        speech = str(speech)
        break
    return speech

Any help or advice would be appreciated!任何帮助或建议将不胜感激!

Note: when I run “arecord -l”, it outputs nothing but “ List of CAPTURE Hardware Devices注意:当我运行“arecord -l”时,它只输出“ List of CAPTURE Hardware Devices

I figured my issue was that I had not installed "flac" on my system, and my microphone was a bit too far away from my face.我想我的问题是我没有在我的系统上安装“flac”,而且我的麦克风离我的脸有点太远了。 To make it fully work, I had to confirm the headset audio type in the Bluetooth bluez menu to make sure it was capable of audio input and output, and I had to add the import of the "pyttsx3" package.为了让它完全工作,我必须在蓝牙 bluez 菜单中确认耳机音频类型以确保它能够进行音频输入和 output,并且我必须添加“pyttsx3”package 的导入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM