Alvin-Nahabwe commited on
Commit
780f607
·
1 Parent(s): a355d31

Updated app.py: added HF_TOKEN and enabled gradio public url sharing

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import gradio as gr
2
  from transformers import pipeline, Wav2Vec2ProcessorWithLM
3
 
@@ -5,13 +6,13 @@ def transcribe(audio, model_id):
5
  # load processor
6
  p = Wav2Vec2ProcessorWithLM.from_pretrained(model_id, revision="lm")
7
  # load eval pipeline
8
- asr = pipeline("automatic-speech-recognition", model=model_id, tokenizer=p.tokenizer, feature_extractor=p.feature_extractor, decoder=p.decoder)
9
 
10
  text = asr(audio)["text"]
11
  return text
12
 
13
  asr_app = gr.Interface(
14
- fn=transcribe,
15
  inputs=[
16
  gr.Audio(sources=["upload", "microphone"], type="filepath"),
17
  gr.Dropdown(
@@ -21,10 +22,10 @@ asr_app = gr.Interface(
21
  "asr-africa/wav2vec2-xls-r-1b-naijavoices-yoruba-500hr-v0"
22
  ]
23
  )
24
- ],
25
  outputs="text",
26
  title="NaijaVoices ASR",
27
  description="Realtime demo for Hausa, Igbo and Yoruba speech recognition using a fine-tuned Wav2Vec-XLS-R 1B model.",
28
  )
29
 
30
- asr_app.launch()
 
1
+ import os
2
  import gradio as gr
3
  from transformers import pipeline, Wav2Vec2ProcessorWithLM
4
 
 
6
  # load processor
7
  p = Wav2Vec2ProcessorWithLM.from_pretrained(model_id, revision="lm")
8
  # load eval pipeline
9
+ asr = pipeline("automatic-speech-recognition", model=model_id, tokenizer=p.tokenizer, feature_extractor=p.feature_extractor, decoder=p.decoder, token=os.getenv('HF_TOKEN'))
10
 
11
  text = asr(audio)["text"]
12
  return text
13
 
14
  asr_app = gr.Interface(
15
+ fn=transcribe,
16
  inputs=[
17
  gr.Audio(sources=["upload", "microphone"], type="filepath"),
18
  gr.Dropdown(
 
22
  "asr-africa/wav2vec2-xls-r-1b-naijavoices-yoruba-500hr-v0"
23
  ]
24
  )
25
+ ],
26
  outputs="text",
27
  title="NaijaVoices ASR",
28
  description="Realtime demo for Hausa, Igbo and Yoruba speech recognition using a fine-tuned Wav2Vec-XLS-R 1B model.",
29
  )
30
 
31
+ asr_app.launch(share=True)