rohitp1 commited on
Commit
c61ab81
·
1 Parent(s): a864a25

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -16
app.py CHANGED
@@ -15,28 +15,28 @@ import time
15
 
16
 
17
  auth_token = os.environ.get('TOKEN')
18
- model1 = WhisperForConditionalGeneration.from_pretrained("rohitp1/kkkh_whisper_small_distillation_att_loss_libri360_epochs_100_batch_4_concat_dataset",
19
- use_auth_token=auth_token)
20
 
21
- tokenizer1 = WhisperTokenizer.from_pretrained("rohitp1/kkkh_whisper_small_distillation_att_loss_libri360_epochs_100_batch_4_concat_dataset",
22
- use_auth_token=auth_token)
23
 
24
- feat_ext1 = WhisperFeatureExtractor.from_pretrained("rohitp1/kkkh_whisper_small_distillation_att_loss_libri360_epochs_100_batch_4_concat_dataset",
25
- use_auth_token=auth_token)
 
26
 
 
 
 
27
 
28
- model2 = WhisperForConditionalGeneration.from_pretrained("rohitp1/dgx2_whisper_small_finetune_teacher_babble_noise_libri_360_hours_50_epochs_batch_8",
29
- use_auth_token=auth_token)
 
30
 
31
- tokenizer2 = WhisperTokenizer.from_pretrained("rohitp1/dgx2_whisper_small_finetune_teacher_babble_noise_libri_360_hours_50_epochs_batch_8",
32
- use_auth_token=auth_token)
33
-
34
- feat_ext2 = WhisperFeatureExtractor.from_pretrained("rohitp1/dgx2_whisper_small_finetune_teacher_babble_noise_libri_360_hours_50_epochs_batch_8",
35
- use_auth_token=auth_token)
36
 
37
 
38
  p1 = pipeline('automatic-speech-recognition', model=model1, tokenizer=tokenizer1, feature_extractor=feat_ext1)
39
  p2 = pipeline('automatic-speech-recognition', model=model2, tokenizer=tokenizer2, feature_extractor=feat_ext2)
 
40
 
41
  def transcribe(mic_input, upl_input, model_type):
42
  if mic_input:
@@ -44,8 +44,10 @@ def transcribe(mic_input, upl_input, model_type):
44
  else:
45
  audio = upl_input
46
  time.sleep(3)
47
- if model_type =='Finetuned':
48
  text = p2(audio)["text"]
 
 
49
  else:
50
  text = p1(audio)["text"]
51
  # state = text + " "
@@ -77,7 +79,7 @@ def transcribe(mic_input, upl_input, model_type):
77
  # demo.launch()
78
 
79
  def clear_inputs_and_outputs():
80
- return [None, None, "RobustDistillation", None]
81
 
82
  # Main function
83
  if __name__ == "__main__":
@@ -100,7 +102,7 @@ if __name__ == "__main__":
100
  )
101
 
102
  with gr.Row():
103
- model_type = gr.inputs.Dropdown(["RobustDistillation", "Finetuned"], label='Model Type')
104
 
105
  with gr.Row():
106
  clr_btn = gr.Button(value="Clear", variant="secondary")
 
15
 
16
 
17
  auth_token = os.environ.get('TOKEN')
 
 
18
 
 
 
19
 
20
+ M1 = "rohitp1/kkkh_whisper_small_distillation_att_loss_libri360_epochs_100_batch_4_concat_dataset"
21
+ M2 = "rohitp1/dgx2_whisper_small_finetune_teacher_babble_noise_libri_360_hours_50_epochs_batch_8"
22
+ M3 = "rohitp1/subhadeep_whisper_small_finetune_teacher_no_noise_libri_360_hours_100_epochs_batch_8"
23
 
24
+ model1 = WhisperForConditionalGeneration.from_pretrained(M1, use_auth_token=auth_token)
25
+ tokenizer1 = WhisperTokenizer.from_pretrained(M1, use_auth_token=auth_token)
26
+ feat_ext1 = WhisperFeatureExtractor.from_pretrained(M1, use_auth_token=auth_token)
27
 
28
+ model2 = WhisperForConditionalGeneration.from_pretrained(M2, use_auth_token=auth_token)
29
+ tokenizer2 = WhisperTokenizer.from_pretrained(M2, use_auth_token=auth_token)
30
+ feat_ext2 = WhisperFeatureExtractor.from_pretrained(M2, use_auth_token=auth_token)
31
 
32
+ model3 = WhisperForConditionalGeneration.from_pretrained(M3, use_auth_token=auth_token)
33
+ tokenizer3 = WhisperTokenizer.from_pretrained(M3, use_auth_token=auth_token)
34
+ feat_ext3 = WhisperFeatureExtractor.from_pretrained(M3, use_auth_token=auth_token)
 
 
35
 
36
 
37
  p1 = pipeline('automatic-speech-recognition', model=model1, tokenizer=tokenizer1, feature_extractor=feat_ext1)
38
  p2 = pipeline('automatic-speech-recognition', model=model2, tokenizer=tokenizer2, feature_extractor=feat_ext2)
39
+ p3 = pipeline('automatic-speech-recognition', model=model3, tokenizer=tokenizer3, feature_extractor=feat_ext3)
40
 
41
  def transcribe(mic_input, upl_input, model_type):
42
  if mic_input:
 
44
  else:
45
  audio = upl_input
46
  time.sleep(3)
47
+ if model_type == 'NoisyFinetuned':
48
  text = p2(audio)["text"]
49
+ elif model_type == 'CleanFinetuned':
50
+ text = p3(audio)["text"]
51
  else:
52
  text = p1(audio)["text"]
53
  # state = text + " "
 
79
  # demo.launch()
80
 
81
  def clear_inputs_and_outputs():
82
+ return [None, None, "CleanFinetuned", None]
83
 
84
  # Main function
85
  if __name__ == "__main__":
 
102
  )
103
 
104
  with gr.Row():
105
+ model_type = gr.inputs.Dropdown(["RobustDistillation", "NoisyFinetuned", "CleanFinetuned"], label='Model Type')
106
 
107
  with gr.Row():
108
  clr_btn = gr.Button(value="Clear", variant="secondary")