Spaces:
Sleeping
Sleeping
Update Logic/SpeachToText.py
Browse files- Logic/SpeachToText.py +7 -7
Logic/SpeachToText.py
CHANGED
@@ -7,13 +7,13 @@ Recognizer=sr.Recognizer()
|
|
7 |
SpeachRouter=APIRouter()
|
8 |
@SpeachRouter.post("/SpeachTotext")
|
9 |
def SpeachToTextEndPoint(Audio:UploadFile):
|
10 |
-
|
11 |
-
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
|
17 |
|
18 |
-
except Exception as e:
|
19 |
-
return {"Status":False,"Message":e}
|
|
|
7 |
SpeachRouter=APIRouter()
|
8 |
@SpeachRouter.post("/SpeachTotext")
|
9 |
def SpeachToTextEndPoint(Audio:UploadFile):
|
10 |
+
# try:
|
11 |
+
with sr.AudioFile(BytesIO(Audio.file.read())) as File:
|
12 |
|
13 |
+
audio=Recognizer.listen(File)
|
14 |
+
Text:str=Recognizer.recognize_google(audio,language="en-US")
|
15 |
+
return { "Status":True,"Message":str(Text)}
|
16 |
|
17 |
|
18 |
+
#except Exception as e:
|
19 |
+
#return {"Status":False,"Message":e}
|