Commit
•
081b40f
1
Parent(s):
f0f7d0e
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,42 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
|
|
4 |
|
5 |
-
transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-small.en")
|
6 |
|
7 |
def transcribe(audio):
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
19 |
)
|
20 |
|
21 |
-
|
22 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import whisper
|
3 |
+
|
4 |
+
MODEL = whisper.load_model("base.en")
|
5 |
|
|
|
6 |
|
7 |
def transcribe(audio):
|
8 |
+
result = MODEL.transcribe(audio)
|
9 |
+
|
10 |
+
try:
|
11 |
+
return result["text"]
|
12 |
+
except:
|
13 |
+
return ""
|
14 |
+
|
15 |
|
16 |
+
examples = [["apollo11_example.mp3"], ["ariane6_example.mp3"]]
|
17 |
|
18 |
+
ui = gr.Interface(
|
19 |
+
fn=transcribe,
|
20 |
+
inputs=gr.Audio(
|
21 |
+
sources=["microphone", "upload"],
|
22 |
+
type="filepath",
|
23 |
+
label="Input Audio",
|
24 |
+
),
|
25 |
+
outputs=gr.Textbox(
|
26 |
+
label="Transcription",
|
27 |
+
placeholder="The transcribed text will appear here...",
|
28 |
+
),
|
29 |
+
title="ECHO",
|
30 |
+
description="""
|
31 |
+
This is a demo of the transcription capabilities of "ECHO". This could be adapded to run real-time transcription on a live audio stream like ISS communications.
|
32 |
|
33 |
+
### How to use:
|
34 |
+
1. **Record or Upload**: Click on the microphone icon 🎙️ to record audio, usign your microphone, or click on the upload button ⬆️ to upload an audio file.
|
35 |
+
You can also use the **Examples** provided below, as inputs, by clicking on them.
|
36 |
+
2. **Click Submit**: Clicking the submit button will transcribe the audio.
|
37 |
+
3. **Read the Transcription**: The transcribed text will appear in the text box below the audio input section.
|
38 |
+
""",
|
39 |
+
examples=examples,
|
40 |
)
|
41 |
|
42 |
+
ui.launch()
|
|