Reorganise gists folder
This commit is contained in:
26
codegrab/speech.py
Normal file
26
codegrab/speech.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import speech_recognition as sr
|
||||
|
||||
recognizer = sr.Recognizer()
|
||||
|
||||
''' recording the sound '''
|
||||
|
||||
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")
|
||||
|
||||
''' Recorgnizing the Audio '''
|
||||
try:
|
||||
print("Recognizing the text")
|
||||
|
||||
text = recognizer.recognize_sphinx(
|
||||
recorded_audio,
|
||||
language="de-DE"
|
||||
)
|
||||
print("Decoded Text : {}".format(text))
|
||||
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
|
||||
Reference in New Issue
Block a user