pgilles commited on
Commit
9ad392d
·
1 Parent(s): 8281394

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -13,8 +13,11 @@ token_key = os.environ.get("HUGGING_FACE_HUB_TOKEN")
13
  model_name = "unilux/whisper-large-v2-lb_cased_01"
14
 
15
  #p = pipeline("automatic-speech-recognition", model=model, tokenizer=tokenizer, feature_extractor=processor.feature_extractor, decoder=processor.decoder, use_auth_token=token_key)
16
- p = pipeline("automatic-speech-recognition", model=model_name, device=0, use_auth_token=token_key)
17
 
 
 
 
18
  def load_data(input_file):
19
 
20
  """ Function for resampling to ensure that the speech input is sampled at 16KHz.
@@ -27,7 +30,7 @@ def load_data(input_file):
27
 
28
  def asr_pipe(input_file, input_file_microphone, chunks):
29
  input_file = input_file_microphone if input_file_microphone else input_file
30
- transcription = p(input_file, chunk_length_s= chunks, stride_length_s = None)["text"]
31
  return transcription
32
 
33
  inputs = [gr.inputs.Audio(source="upload", type='filepath', label="Eng Audio-Datei eroplueden...", optional = True),
 
13
  model_name = "unilux/whisper-large-v2-lb_cased_01"
14
 
15
  #p = pipeline("automatic-speech-recognition", model=model, tokenizer=tokenizer, feature_extractor=processor.feature_extractor, decoder=processor.decoder, use_auth_token=token_key)
16
+ pipe = pipeline("automatic-speech-recognition", model=model_name, device=0, use_auth_token=token_key)
17
 
18
+ pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(
19
+ language=lang, task="transcribe"
20
+
21
  def load_data(input_file):
22
 
23
  """ Function for resampling to ensure that the speech input is sampled at 16KHz.
 
30
 
31
  def asr_pipe(input_file, input_file_microphone, chunks):
32
  input_file = input_file_microphone if input_file_microphone else input_file
33
+ transcription = pipe(input_file, chunk_length_s= 30)["text"]
34
  return transcription
35
 
36
  inputs = [gr.inputs.Audio(source="upload", type='filepath', label="Eng Audio-Datei eroplueden...", optional = True),