0

重现问题的步骤(似乎仅限 PC):

  1. 加入 Zoom 或 Discord 群组通话,确保您可以听到通话中的其他人
  2. 使用基本的语音识别代码,如下所示
  3. 现在无法再听到其他人在通话中

离开并重新进入可以解决问题,在步骤 2 中的音频切断后更改扬声器输出也是如此。

这是一些基本代码。请注意,在某些时候,我确实发现这可以在不切断 Discord 通话的音频的情况下工作,所以我猜他们的一端有一些断断续续的东西——我只是想弄清楚如何在我的一端很好地处理它。

import speech_recognition as sr


r = sr.Recognizer()
m = sr.Microphone()    

with m as source:
    r.adjust_for_ambient_noise(source)

    while(True):            
        
        print("Please say something...")
    
        audio = r.listen(source)
    
        command = ""
    
        try:
            # All the getting command stuff. 0 is a dummy number
            command = r.recognize_google(audio)
    
            print("You said : \n " + command)
            
            if command.lower() == "quit": break
    
        except:
            print("Error getting command from microphone")
4

0 回答 0