From c732a1ed9c7f82a4a80540270f46bc33bd8f80d9 Mon Sep 17 00:00:00 2001 From: Gundeep Singh Saluja Date: Fri, 9 Oct 2020 23:35:01 +0530 Subject: [PATCH] Added a python program to record voice --- voice_recorder.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 voice_recorder.py diff --git a/voice_recorder.py b/voice_recorder.py new file mode 100644 index 0000000..85657d7 --- /dev/null +++ b/voice_recorder.py @@ -0,0 +1,24 @@ +import speech_recognition as sr +def voice_recorder(): + r = sr.Recognizer() + with sr.Microphone() as source: + print("Recording...") + r.energy_threshold = 100 + r.pause_threshold = 3 + audio = r.listen(source) + + try: + print("Recognizing...") + speech = r.recognize_google(audio) + print("Recorded successfully!") + + except Exception as e: + print("Not clear") + + with open("recordedaudio.wav", "wb") as f: + f.write(audio.get_wav_data()) + + + +if __name__ == "__main__": + voice_recorder() \ No newline at end of file