leophill commited on
Commit
8d491d1
·
1 Parent(s): 29d3942

update to pipeline, model and processor

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -1,6 +1,6 @@
1
  # from: https://gradio.app/real_time_speech_recognition/
2
 
3
- from transformers import pipeline
4
  import torch
5
  import gradio as gr
6
  import librosa
@@ -15,10 +15,12 @@ print("key length:", len(token_key.strip()))
15
  model_name = "pgilles/whisper-large-v2-lb_cased_04"
16
  #model_name = "pgilles/whisper-large-10_Chamber" # model too bad
17
 
18
- model = WhisperForConditionalGeneration.from_pretrained(best_asr_model, use_auth_token=token_key)
 
 
19
  #p = pipeline("automatic-speech-recognition", model=model, tokenizer=tokenizer, feature_extractor=processor.feature_extractor, decoder=processor.decoder, use_auth_token=token_key)
20
 
21
- pipe = pipeline("automatic-speech-recognition", model=model, device=0)
22
  #pipe = pipeline("automatic-speech-recognition", model=model_name, device=0, use_auth_token=token_key)
23
  #pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language= "Luxembourgish", task="transcribe")
24
  #pipe.model.config.forced_decoder_ids = None
 
1
  # from: https://gradio.app/real_time_speech_recognition/
2
 
3
+ from transformers import pipeline, WhisperProcessor, WhisperForConditionalGeneration
4
  import torch
5
  import gradio as gr
6
  import librosa
 
15
  model_name = "pgilles/whisper-large-v2-lb_cased_04"
16
  #model_name = "pgilles/whisper-large-10_Chamber" # model too bad
17
 
18
+ processor = WhisperProcessor.from_pretrained(model_name, language="lb", task="transcribe")
19
+ tokenizer = processor.tokenizer
20
+ model = WhisperForConditionalGeneration.from_pretrained(model_name, use_auth_token=token_key)
21
  #p = pipeline("automatic-speech-recognition", model=model, tokenizer=tokenizer, feature_extractor=processor.feature_extractor, decoder=processor.decoder, use_auth_token=token_key)
22
 
23
+ pipe = pipeline("automatic-speech-recognition", model=model, tokenizer=processor.tokenizer, feature_extractor=processor.feature_extractor, decoder=processor.decoder, device=0)
24
  #pipe = pipeline("automatic-speech-recognition", model=model_name, device=0, use_auth_token=token_key)
25
  #pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language= "Luxembourgish", task="transcribe")
26
  #pipe.model.config.forced_decoder_ids = None