Spaces:
Sleeping
Sleeping
Create ap.py
Browse files
ap.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import librosa
|
| 3 |
+
from asr import transcribe, ASR_EXAMPLES, ASR_LANGUAGES, ASR_NOTE
|
| 4 |
+
|
| 5 |
+
# Speech-to-Text Interface
|
| 6 |
+
mms_transcribe = gr.Interface(
|
| 7 |
+
fn=transcribe,
|
| 8 |
+
inputs=[
|
| 9 |
+
gr.Audio(),
|
| 10 |
+
gr.Dropdown(
|
| 11 |
+
[f"{k} ({v})" for k, v in ASR_LANGUAGES.items()],
|
| 12 |
+
label="Language",
|
| 13 |
+
value="eng English",
|
| 14 |
+
),
|
| 15 |
+
],
|
| 16 |
+
outputs="text",
|
| 17 |
+
examples=ASR_EXAMPLES,
|
| 18 |
+
title="Speech-to-Text",
|
| 19 |
+
description="Transcribe audio from a microphone or input file in your desired language.",
|
| 20 |
+
article=ASR_NOTE,
|
| 21 |
+
allow_flagging="never",
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
# Main Gradio App
|
| 25 |
+
with gr.Blocks() as demo:
|
| 26 |
+
gr.Markdown("<p align='center' style='font-size: 20px;'>MMS Speech-to-Text</p>")
|
| 27 |
+
gr.HTML("<center>Convert speech to text in multiple languages.</center>")
|
| 28 |
+
|
| 29 |
+
mms_transcribe.render()
|
| 30 |
+
|
| 31 |
+
if __name__ == "__main__":
|
| 32 |
+
demo.queue()
|
| 33 |
+
demo.launch()
|
| 34 |
+
|