nambn0321 commited on
Commit
1a32b6e
·
verified ·
1 Parent(s): dcd263b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -7
app.py CHANGED
@@ -1,19 +1,32 @@
1
  from transformers import pipeline
2
  import gradio as gr
 
3
 
4
- # Explicitly set the task
5
- pipe = pipeline("automatic-speech-recognition", model="nambn0321/ASR_french_3")
 
 
 
 
 
 
 
 
 
6
 
7
  def transcribe(audio):
8
- text = pipe(audio)["text"]
9
- return text
 
 
 
10
 
11
  iface = gr.Interface(
12
  fn=transcribe,
13
- inputs=gr.Audio(type="filepath"), # Removed source="microphone"
14
  outputs="text",
15
  title="Whisper Small French",
16
- description="Realtime demo for French speech recognition using a fine-tuned Whisper small model.",
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()