Edward Tan commited on
Commit
5a22ed5
·
1 Parent(s): e9e2074

Correcting app.py error

Browse files
Files changed (2) hide show
  1. app.py +11 -10
  2. wav2vec2_model_pipeline/model.safetensors +1 -1
app.py CHANGED
@@ -5,12 +5,15 @@ local_model_name = "wav2vec2_model_pipeline"
5
  speech_recognizer = pipeline("automatic-speech-recognition", model = local_model_name)
6
 
7
  def greet_and_transcribe(name, intensity, input_audio):
8
- input_audio_rs = librosa.resample(
9
- input_audio[1].astype(float),
10
- orig_sr=input_audio[0],
11
- target_sr=speech_recognizer.feature_extractor.sampling_rate)
12
- transcribed_audio = speech_recognizer(input_audio_rs)["text"]
13
- return "Hello, " + name + "!" * int(intensity), transcribed_audio
 
 
 
14
 
15
  demo = gr.Interface(
16
  title="A simple audio transcribing model",
@@ -21,9 +24,7 @@ demo = gr.Interface(
21
  gr.Text(placeholder="input your name here"),
22
  gr.Slider(minimum=1, maximum=5, value=3),
23
  gr.Audio()],
24
- outputs=["text", "text"],
25
- cache_examples="lazy",
26
- allow_flagging="auto",
27
- # article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
28
  )
29
  demo.launch(share=True)
 
5
  speech_recognizer = pipeline("automatic-speech-recognition", model = local_model_name)
6
 
7
  def greet_and_transcribe(name, intensity, input_audio):
8
+ try:
9
+ input_audio_rs = librosa.resample(
10
+ input_audio[1].astype(float),
11
+ orig_sr=input_audio[0],
12
+ target_sr=speech_recognizer.feature_extractor.sampling_rate)
13
+ transcribed_audio = speech_recognizer(input_audio_rs)["text"]
14
+ return "Hello, " + name + "!" * int(intensity), transcribed_audio
15
+ except Exception as err:
16
+ return "Hello, " + name + "!" * int(intensity), err
17
 
18
  demo = gr.Interface(
19
  title="A simple audio transcribing model",
 
24
  gr.Text(placeholder="input your name here"),
25
  gr.Slider(minimum=1, maximum=5, value=3),
26
  gr.Audio()],
27
+ outputs=[gr.Text(label="Greeting"), gr.Text(label="Transcribed output")],
28
+ allow_flagging="auto"
 
 
29
  )
30
  demo.launch(share=True)
wav2vec2_model_pipeline/model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ecc0894f391d5a74a066563afb948f12e0b60118d6958a62276bbb062546149d
3
  size 377611120
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4555726530352261d56919d55eae9002a57ba5c78a6f9d1fbe384ba838b30c61
3
  size 377611120