Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,22 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load Wav2Vec 2.0
|
5 |
asr = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-960h")
|
6 |
|
7 |
-
# Function to
|
8 |
def transcribe(audio):
|
9 |
-
|
10 |
-
|
|
|
11 |
|
12 |
-
# Gradio
|
13 |
interface = gr.Interface(
|
14 |
fn=transcribe,
|
15 |
-
inputs=gr.Audio(
|
16 |
outputs=gr.Textbox(label="Transcribed Text"),
|
17 |
-
title="Wav2Vec 2.0 Speech
|
18 |
-
description="
|
19 |
)
|
20 |
|
21 |
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load Wav2Vec 2.0 speech recognition model
|
5 |
asr = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-960h")
|
6 |
|
7 |
+
# Function to process audio and return transcribed text
|
8 |
def transcribe(audio):
|
9 |
+
if audio is None:
|
10 |
+
return "No audio provided."
|
11 |
+
return asr(audio)["text"]
|
12 |
|
13 |
+
# Gradio Interface
|
14 |
interface = gr.Interface(
|
15 |
fn=transcribe,
|
16 |
+
inputs=gr.Audio(type="filepath", label="Upload or Record Audio"),
|
17 |
outputs=gr.Textbox(label="Transcribed Text"),
|
18 |
+
title="🎤 Wav2Vec 2.0 - Speech to Text",
|
19 |
+
description="Upload or record an audio file and get the transcribed text using Facebook's Wav2Vec 2.0."
|
20 |
)
|
21 |
|
22 |
interface.launch()
|