Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,21 +10,20 @@ pipe = pipeline(
|
|
| 10 |
|
| 11 |
# Define the transcription function for audio input
|
| 12 |
def transcribe_audio(audio):
|
| 13 |
-
|
| 14 |
prediction = pipe(audio, batch_size=8, return_timestamps=True)["chunks"]
|
| 15 |
|
| 16 |
-
# Format the output to show text with timestamps
|
| 17 |
transcription = "\n".join([f"[{chunk['timestamp'][0]:.2f}s - {chunk['timestamp'][1]:.2f}s] {chunk['text']}" for chunk in prediction])
|
| 18 |
|
| 19 |
return transcription
|
| 20 |
|
| 21 |
# Create a Gradio interface
|
| 22 |
interface = gr.Interface(
|
| 23 |
-
fn=transcribe_audio,
|
| 24 |
-
inputs=gr.Audio(type="filepath"),
|
| 25 |
-
outputs="text",
|
| 26 |
-
title="Whisper Small ASR",
|
| 27 |
-
description="Upload or record audio for transcription using Whisper Small."
|
| 28 |
)
|
| 29 |
|
| 30 |
# Launch the Gradio app
|
|
|
|
| 10 |
|
| 11 |
# Define the transcription function for audio input
|
| 12 |
def transcribe_audio(audio):
|
| 13 |
+
|
| 14 |
prediction = pipe(audio, batch_size=8, return_timestamps=True)["chunks"]
|
| 15 |
|
|
|
|
| 16 |
transcription = "\n".join([f"[{chunk['timestamp'][0]:.2f}s - {chunk['timestamp'][1]:.2f}s] {chunk['text']}" for chunk in prediction])
|
| 17 |
|
| 18 |
return transcription
|
| 19 |
|
| 20 |
# Create a Gradio interface
|
| 21 |
interface = gr.Interface(
|
| 22 |
+
fn=transcribe_audio,
|
| 23 |
+
inputs=gr.Audio(type="filepath"),
|
| 24 |
+
outputs="text",
|
| 25 |
+
title="Whisper Small ASR",
|
| 26 |
+
description="Upload or record audio for transcription using Whisper Small."
|
| 27 |
)
|
| 28 |
|
| 29 |
# Launch the Gradio app
|