leophill commited on
Commit
07459bd
·
1 Parent(s): 09cbba9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -1,17 +1,24 @@
1
  # from: https://gradio.app/real_time_speech_recognition/
2
 
3
- from transformers import pipeline
4
  import pyctcdecode
5
  import kenlm
6
  import gradio as gr
7
  import librosa
8
  import os
 
9
 
10
  #Loading the model and the tokenizer
11
  token_key = os.environ.get("HUGGING_FACE_HUB_TOKEN")
12
  #model_name = "unilux/wav2vec-xls-r-Luxembourgish20-with-LM"
13
- model_name = "unilux/wav2vec-xlsr-300m-Luxembourgish"
14
- p = pipeline("automatic-speech-recognition", model=model_name, use_auth_token = token_key)
 
 
 
 
 
 
15
  #p = pipeline("automatic-speech-recognition", model=model_name, use_auth_token = True)
16
 
17
  #tokenizer = Wav2Vec2Tokenizer.from_pretrained(model_name)
 
1
  # from: https://gradio.app/real_time_speech_recognition/
2
 
3
+ from transformers import pipeline, Wav2Vec2CTCTokenizer, Wav2Vec2ForCTC, Wav2Vec2ProcessorWithLM
4
  import pyctcdecode
5
  import kenlm
6
  import gradio as gr
7
  import librosa
8
  import os
9
+ import time
10
 
11
  #Loading the model and the tokenizer
12
  token_key = os.environ.get("HUGGING_FACE_HUB_TOKEN")
13
  #model_name = "unilux/wav2vec-xls-r-Luxembourgish20-with-LM"
14
+ model_name = "unilux/wav2vec-xlsr-300m-Luxembourgish-with-LM"
15
+ tokenizer = Wav2Vec2CTCTokenizer.from_pretrained(model_name, use_auth_token=token_key)
16
+ model = Wav2Vec2ForCTC.from_pretrained(model_name, use_auth_token=token_key)
17
+ processor = Wav2Vec2ProcessorWithLM.from_pretrained(model_name, use_auth_token=token_key)
18
+
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
+ #p = pipeline("automatic-speech-recognition", model=model_name, use_auth_token = token_key)
22
  #p = pipeline("automatic-speech-recognition", model=model_name, use_auth_token = True)
23
 
24
  #tokenizer = Wav2Vec2Tokenizer.from_pretrained(model_name)