prasanth345 commited on
Commit
d0c3e80
·
verified ·
1 Parent(s): 090be3b

Create stt.py

Browse files
Files changed (1) hide show
  1. utils/stt.py +10 -0
utils/stt.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import speech_recognition as sr
2
+
3
+ def speech_to_text(audio_path):
4
+ recognizer = sr.Recognizer()
5
+ with sr.AudioFile(audio_path) as source:
6
+ audio_data = recognizer.record(source)
7
+ try:
8
+ return recognizer.recognize_google(audio_data)
9
+ except sr.UnknownValueError:
10
+ return "Sorry, I could not understand your request."