Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,6 @@ from transformers import (
|
|
9 |
)
|
10 |
|
11 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
12 |
-
|
13 |
model_id = "sudoping01/whosper-large"
|
14 |
|
15 |
# Load model and create pipeline
|
@@ -18,7 +17,7 @@ model = WhisperForConditionalGeneration.from_pretrained(
|
|
18 |
device_map="auto",
|
19 |
use_cache=True,
|
20 |
attention_dropout=0.1,
|
21 |
-
dropout=0.1,
|
22 |
token=os.environ.get("HF_TOKEN")
|
23 |
)
|
24 |
|
@@ -44,13 +43,13 @@ pipe = pipeline(
|
|
44 |
batch_size=1
|
45 |
)
|
46 |
|
47 |
-
def transcribe(
|
48 |
-
if
|
49 |
return "Please provide an audio input."
|
50 |
|
51 |
try:
|
52 |
result = pipe(
|
53 |
-
|
54 |
generate_kwargs={
|
55 |
"temperature": 0.0,
|
56 |
"do_sample": False,
|
@@ -67,10 +66,10 @@ def transcribe(audio_path):
|
|
67 |
demo = gr.Interface(
|
68 |
fn=transcribe,
|
69 |
inputs=[
|
70 |
-
gr.Audio(
|
71 |
],
|
72 |
outputs=gr.Textbox(label="Transcription"),
|
73 |
-
title="Multilingual Speech Recognition: Wolof, French, English, .. or Mix
|
74 |
description="Upload an audio file or record audio to transcribe Wolof, French, or English speech...",
|
75 |
theme="default",
|
76 |
enable_queue=True
|
|
|
9 |
)
|
10 |
|
11 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
|
|
12 |
model_id = "sudoping01/whosper-large"
|
13 |
|
14 |
# Load model and create pipeline
|
|
|
17 |
device_map="auto",
|
18 |
use_cache=True,
|
19 |
attention_dropout=0.1,
|
20 |
+
dropout=0.1,
|
21 |
token=os.environ.get("HF_TOKEN")
|
22 |
)
|
23 |
|
|
|
43 |
batch_size=1
|
44 |
)
|
45 |
|
46 |
+
def transcribe(audio):
|
47 |
+
if audio is None:
|
48 |
return "Please provide an audio input."
|
49 |
|
50 |
try:
|
51 |
result = pipe(
|
52 |
+
audio,
|
53 |
generate_kwargs={
|
54 |
"temperature": 0.0,
|
55 |
"do_sample": False,
|
|
|
66 |
demo = gr.Interface(
|
67 |
fn=transcribe,
|
68 |
inputs=[
|
69 |
+
gr.Audio(sources=["microphone", "upload"], type="filepath")
|
70 |
],
|
71 |
outputs=gr.Textbox(label="Transcription"),
|
72 |
+
title="Multilingual Speech Recognition: Wolof, French, English, .. or Mix",
|
73 |
description="Upload an audio file or record audio to transcribe Wolof, French, or English speech...",
|
74 |
theme="default",
|
75 |
enable_queue=True
|