I am trying to take audio input and save it as.wav file.
My code is the following:
import speech_recognition as sr
def save():
r=sr.Recognizer()
r.pause_threshold = 0.6
with sr.Microphone() as source:
print('Yes')
audio=r.listen(source)
with open('test.wav','wb') as wav:
wav.write(audio.get_wav_data())
save()
If I save and run this file it listens forever or till I terminate the code.
Can anybody help me.
Thank you
- Levers
import speech_recognition as sr
def save():
r=sr.Recognizer()
r.pause_threshold = 0.6
with sr.Microphone() as source:
print('Yes')
r.adjust_for_ambient_noise(source)
audio=r.listen(source)
with open('test.wav','wb') as wav:
wav.write(audio.get_wav_data())
save()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.