Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,32 @@
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
def transcribe(audio):
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
iface = gr.Interface(
|
| 12 |
fn=transcribe,
|
| 13 |
-
inputs=gr.Audio(type="filepath"),
|
| 14 |
outputs="text",
|
| 15 |
title="Whisper Small French",
|
| 16 |
-
description="
|
| 17 |
)
|
| 18 |
|
| 19 |
-
iface.launch()
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
+
import traceback
|
| 4 |
|
| 5 |
+
try:
|
| 6 |
+
print("Loading model...")
|
| 7 |
+
pipe = pipeline(
|
| 8 |
+
task="automatic-speech-recognition",
|
| 9 |
+
model="nambn0321/ASR_french_3"
|
| 10 |
+
)
|
| 11 |
+
print("Model loaded successfully!")
|
| 12 |
+
except Exception as e:
|
| 13 |
+
print("ERROR LOADING MODEL:")
|
| 14 |
+
traceback.print_exc()
|
| 15 |
+
pipe = None
|
| 16 |
|
| 17 |
def transcribe(audio):
|
| 18 |
+
if pipe is None:
|
| 19 |
+
return "Model failed to load. Check logs."
|
| 20 |
+
|
| 21 |
+
result = pipe(audio)
|
| 22 |
+
return result["text"]
|
| 23 |
|
| 24 |
iface = gr.Interface(
|
| 25 |
fn=transcribe,
|
| 26 |
+
inputs=gr.Audio(type="filepath"),
|
| 27 |
outputs="text",
|
| 28 |
title="Whisper Small French",
|
| 29 |
+
description="French speech recognition"
|
| 30 |
)
|
| 31 |
|
| 32 |
+
iface.launch()
|