diff --git a/app.py b/app.py new file mode 100644 index 0000000..c79c4d4 --- /dev/null +++ b/app.py @@ -0,0 +1,26 @@ +import speech_recognition as sr + +recognizer = sr.Recognizer() + +with sr.Microphone() as source: + print("Adjusting noise ") + recognizer.adjust_for_ambient_noise(source, duration=1) + print("Recording for 4 seconds") + recorded_audio = recognizer.listen(source, timeout=4) + print("Done recording") + +try: + print("Recognizing the text") + text = recognizer.recognize_google( + recorded_audio, + language="en-US" + ) + + print("Decoded Text : {}".format(text)) + +except Exception as ex: + + print(ex) + + +sr.Microphone.list_microphone_names() \ No newline at end of file diff --git a/app_audio.py b/app_audio.py new file mode 100644 index 0000000..88819bd --- /dev/null +++ b/app_audio.py @@ -0,0 +1,21 @@ +import speech_recognition as sr + +recognizer = sr.Recognizer() + +''' recording the sound ''' + +with sr.AudioFile("./sample_audio/speech.wav") as source: + recorded_audio = recognizer.listen(source) + print("Done recording") + +''' Recorgnizing the Audio ''' +try: + print("Recognizing the text") + text = recognizer.recognize_google( + recorded_audio, + language="en-US" + ) + print("Decoded Text : {}".format(text)) + +except Exception as ex: + print(ex) \ No newline at end of file diff --git a/sample_audio/speech.wav b/sample_audio/speech.wav new file mode 100644 index 0000000..a8522b1 Binary files /dev/null and b/sample_audio/speech.wav differ