Spaces:
Sleeping
Sleeping
Commit
·
396b569
1
Parent(s):
e7301f5
up
Browse files
app.py
CHANGED
@@ -4,27 +4,19 @@ os.system("sudo apt-get update")
|
|
4 |
os.system("apt install libasound2-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg")
|
5 |
# import sounddevice as sd
|
6 |
import speech_recognition as sr
|
7 |
-
def
|
8 |
-
|
9 |
-
with sr.AudioFile(
|
10 |
-
audio
|
11 |
-
) as source: # Replace "audio.wav" with the path to your .wav file
|
12 |
-
# print("Listening...")
|
13 |
-
audio_data = r.record(source)
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
query = r.recognize_google(audio_data, language="en-in")
|
18 |
-
print(f"User said: {query}")
|
19 |
-
return query
|
20 |
-
except sr.UnknownValueError:
|
21 |
-
print("Unable to recognize speech")
|
22 |
-
except sr.RequestError as e:
|
23 |
-
print(f"Error occurred: {e}")
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
26 |
|
27 |
|
28 |
|
29 |
-
k=gr.Interface(fn=takeCommand, inputs=gr.Audio(source="upload", type="filepath"), outputs="text")
|
30 |
k.launch()
|
|
|
4 |
os.system("apt install libasound2-dev portaudio19-dev libportaudio2 libportaudiocpp0 ffmpeg")
|
5 |
# import sounddevice as sd
|
6 |
import speech_recognition as sr
|
7 |
+
def translate(audio_path:str,lang:str):
|
8 |
+
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
with sr.AudioFile(audio_path) as source:
|
11 |
+
audio = recognizer.record(source)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
try:
|
14 |
+
spoken_text = recognizer.recognize_google(audio,language=lang)
|
15 |
+
return spoken_text
|
16 |
+
except:
|
17 |
+
gr.Error("some error rised")
|
18 |
|
19 |
|
20 |
|
21 |
+
k=gr.Interface(fn=takeCommand, inputs=[gr.Audio(source="upload", type="filepath"),gr.Text(label="lang")], outputs="text")
|
22 |
k.launch()
|