Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
|
2 |
from transformers import pipeline
|
3 |
import gradio as gr
|
4 |
|
@@ -8,10 +7,10 @@ pipe = pipeline(model="jsbeaudry/whisper-medium-oswald")
|
|
8 |
print("Model loaded successfully.")
|
9 |
|
10 |
# Transcription function
|
11 |
-
def transcribe(
|
12 |
-
if
|
13 |
return "Please upload or record an audio file first."
|
14 |
-
result = pipe(
|
15 |
return result["text"]
|
16 |
|
17 |
# Build Gradio interface
|
@@ -24,16 +23,11 @@ def create_interface():
|
|
24 |
)
|
25 |
|
26 |
with gr.Row():
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
transcribe_button = gr.Button("π Transcribe")
|
32 |
-
output_text = gr.Textbox(label="π Transcribed Text", lines=4)
|
33 |
-
|
34 |
-
|
35 |
transcribe_button.click(fn=transcribe, inputs=audio_input, outputs=output_text)
|
36 |
-
transcribe_button.click(fn=transcribe, inputs=audio_input2, outputs=output_text)
|
37 |
|
38 |
return demo
|
39 |
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
import gradio as gr
|
3 |
|
|
|
7 |
print("Model loaded successfully.")
|
8 |
|
9 |
# Transcription function
|
10 |
+
def transcribe(audio):
|
11 |
+
if audio is None:
|
12 |
return "Please upload or record an audio file first."
|
13 |
+
result = pipe(audio)
|
14 |
return result["text"]
|
15 |
|
16 |
# Build Gradio interface
|
|
|
23 |
)
|
24 |
|
25 |
with gr.Row():
|
26 |
+
audio_input = gr.Audio(label="π§ Upload or Record Audio", format="wav")
|
27 |
+
transcribe_button = gr.Button("π Transcribe")
|
28 |
+
output_text = gr.Textbox(label="π Transcribed Text", lines=4)
|
29 |
+
|
|
|
|
|
|
|
|
|
30 |
transcribe_button.click(fn=transcribe, inputs=audio_input, outputs=output_text)
|
|
|
31 |
|
32 |
return demo
|
33 |
|