Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
|
4 |
-
def
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
8 |
|
9 |
-
interface = gr.Interface(
|
10 |
-
|
11 |
-
inputs=gr.Audio(source="microphone", type="filepath", label="Input Audio"),
|
12 |
-
outputs="text",
|
13 |
-
live=True,
|
14 |
-
title="Speech to Text - Persian",
|
15 |
-
description="Record your voice in Persian and see the transcription here."
|
16 |
-
)
|
17 |
-
|
18 |
-
if __name__ == "__main__":
|
19 |
-
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import torchaudio
|
3 |
|
4 |
+
def transcribe(audio):
|
5 |
+
recognizer = sr.Recognizer()
|
6 |
+
with sr.AudioFile(audio) as source:
|
7 |
+
audio_data = recognizer.record(source)
|
8 |
+
text = recognizer.recognize_google(audio_data, language="fa-IR")
|
9 |
+
return text
|
10 |
|
11 |
+
interface = gr.Interface(fn=transcribe, inputs="microphone", outputs="text")
|
12 |
+
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|