speech_recognition
speech_recognition copied to clipboard
Speech Recognition with Virtual Cable Microphone Distorted.
I use speech_recognition with a Virtual Cable (https://vb-audio.com/Cable/). The issue is speech_recogniton captures a very distorted sound regardless if I speak or not. Recorded Sound [Headphone warning]: https://youtu.be/q78puE0Tdjc
However, this only happens with the speech_recognition package. If I use the Virtual Cable and use it in OBS as a microphone I hear everything perfectly fine. I also checked the sample rate and 44100 Hz seems to be correct.
Code:
def record_audio(audio_queue, energy, pause, dynamic_energy, save_file, temp_dir):
r = sr.Recognizer()
r.pause_threshold = 2
r.non_speaking_duration = 1
microphone_name = "CABLE-B Output (VB-Audio Cable B)"
microphone_index = find_index(microphone_name)
with sr.Microphone(device_index=microphone_index, sample_rate=44100) as source:
r.adjust_for_ambient_noise(source, duration=10)
r.dynamic_energy_threshold = True
save_file = True
while True:
#get and save audio to wav file
audio = r.listen(source)
if save_file:
data = io.BytesIO(audio.get_wav_data())
audio_clip = AudioSegment.from_file(data)
filename = f"./temp.wav"
audio_clip.export(filename, format="wav")
System Information: Windows 10, Python 3.9, speech_regonition==3.10.0