JCrimson1 commited on
Commit
612763b
·
verified ·
1 Parent(s): acd50e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -3,16 +3,14 @@ import librosa
3
  from speechbrain.inference.classifiers import EncoderClassifier
4
  from pydub import AudioSegment
5
  import gradio as gr
6
- import os
7
 
8
- # Load model only once
9
  classifier = EncoderClassifier.from_hparams(
10
  source="Jzuluaga/accent-id-commonaccent_ecapa",
11
- savedir="pretrained_models/accent-id-commonaccent_ecapa"
12
  )
13
 
14
  def classify_accent(video):
15
- # 'video' will already be a path to the uploaded file
16
  audio = AudioSegment.from_file(video, format="mp4")
17
  audio.export("output.wav", format="wav")
18
 
@@ -24,10 +22,13 @@ def classify_accent(video):
24
 
25
  return f"Accent: {text_lab[0]} (Confidence: {score.item():.2f})"
26
 
27
-
28
- iface = gr.Interface(fn=classify_accent,
29
- inputs=gr.Video(),
30
- outputs="text")
 
 
 
31
 
32
  if __name__ == "__main__":
33
- iface.launch()
 
3
  from speechbrain.inference.classifiers import EncoderClassifier
4
  from pydub import AudioSegment
5
  import gradio as gr
 
6
 
7
+ # Load model once
8
  classifier = EncoderClassifier.from_hparams(
9
  source="Jzuluaga/accent-id-commonaccent_ecapa",
10
+ savedir="/tmp/accent-id-commonaccent_ecapa"
11
  )
12
 
13
  def classify_accent(video):
 
14
  audio = AudioSegment.from_file(video, format="mp4")
15
  audio.export("output.wav", format="wav")
16
 
 
22
 
23
  return f"Accent: {text_lab[0]} (Confidence: {score.item():.2f})"
24
 
25
+ app = gr.Interface(
26
+ fn=classify_accent,
27
+ inputs=gr.Video(label="Upload an MP4"),
28
+ outputs=gr.Text(label="Prediction"),
29
+ title="English Accent Classifier",
30
+ description="Upload a short MP4 video of spoken English to detect accent."
31
+ )
32
 
33
  if __name__ == "__main__":
34
+ app.launch()