rohitp1 commited on
Commit
fea3170
·
1 Parent(s): 0d0421b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -26,7 +26,7 @@ feat_ext = WhisperFeatureExtractor.from_pretrained("rohitp1/kkkh_whisper_small_d
26
 
27
  p = pipeline('automatic-speech-recognition', model=model, tokenizer=tokenizer, feature_extractor=feat_ext)
28
 
29
- def transcribe(mic_input, upl_input):
30
  if mic_input:
31
  audio = mic_input
32
  else:
@@ -34,7 +34,7 @@ def transcribe(mic_input, upl_input):
34
  time.sleep(3)
35
  text = p(audio)["text"]
36
  # state = text + " "
37
- return text
38
 
39
 
40
 
@@ -62,7 +62,7 @@ def transcribe(mic_input, upl_input):
62
  # demo.launch()
63
 
64
  def clear_inputs_and_outputs():
65
- return [None, None, None]
66
 
67
  # Main function
68
  if __name__ == "__main__":
@@ -84,10 +84,14 @@ if __name__ == "__main__":
84
  source="upload", type="filepath", label="Upload a wav file"
85
  )
86
 
 
 
 
87
  with gr.Row():
88
  clr_btn = gr.Button(value="Clear", variant="secondary")
89
  prd_btn = gr.Button(value="Predict")
90
 
 
91
  # Outputs
92
  with gr.Column():
93
  lbl_output = gr.Label(label="Top Predictions")
@@ -111,11 +115,11 @@ if __name__ == "__main__":
111
  clr_btn.click(
112
  fn=clear_inputs_and_outputs,
113
  inputs=[],
114
- outputs=[mic_input, upl_input, lbl_output],
115
  )
116
  prd_btn.click(
117
  fn=transcribe,
118
- inputs=[mic_input, upl_input],
119
  outputs=[lbl_output],
120
  )
121
 
 
26
 
27
  p = pipeline('automatic-speech-recognition', model=model, tokenizer=tokenizer, feature_extractor=feat_ext)
28
 
29
+ def transcribe(mic_input, upl_input, model_type):
30
  if mic_input:
31
  audio = mic_input
32
  else:
 
34
  time.sleep(3)
35
  text = p(audio)["text"]
36
  # state = text + " "
37
+ return text+" "+model_type
38
 
39
 
40
 
 
62
  # demo.launch()
63
 
64
  def clear_inputs_and_outputs():
65
+ return [None, None, None, None]
66
 
67
  # Main function
68
  if __name__ == "__main__":
 
84
  source="upload", type="filepath", label="Upload a wav file"
85
  )
86
 
87
+ with gr.Row():
88
+ model_type = gr.inputs.Dropdown("gpt2", "distilgpt2"], type="text", label='Model Type')
89
+
90
  with gr.Row():
91
  clr_btn = gr.Button(value="Clear", variant="secondary")
92
  prd_btn = gr.Button(value="Predict")
93
 
94
+
95
  # Outputs
96
  with gr.Column():
97
  lbl_output = gr.Label(label="Top Predictions")
 
115
  clr_btn.click(
116
  fn=clear_inputs_and_outputs,
117
  inputs=[],
118
+ outputs=[mic_input, upl_input, model_type, lbl_output],
119
  )
120
  prd_btn.click(
121
  fn=transcribe,
122
+ inputs=[mic_input, upl_input, model_type],
123
  outputs=[lbl_output],
124
  )
125