Spaces:
Sleeping
Sleeping
Antoniskaraolis
commited on
Commit
·
a26860c
1
Parent(s):
3ba0490
app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import speech_recognition as sr
|
3 |
+
|
4 |
+
def transcribe_audio(file_info):
|
5 |
+
recognizer = sr.Recognizer()
|
6 |
+
audio_file = file_info['content']
|
7 |
+
|
8 |
+
with sr.AudioFile(audio_file) as source:
|
9 |
+
audio_data = recognizer.record(source)
|
10 |
+
try:
|
11 |
+
text = recognizer.recognize_google(audio_data)
|
12 |
+
return text
|
13 |
+
except Exception as e:
|
14 |
+
return f"Error: {str(e)}"
|
15 |
+
|
16 |
+
iface = gr.Interface(
|
17 |
+
fn=transcribe_audio,
|
18 |
+
inputs=gr.inputs.Audio(source="microphone", type="file"),
|
19 |
+
outputs="text"
|
20 |
+
)
|
21 |
+
|
22 |
+
iface.launch()
|