Kamtera commited on
Commit
d320d92
1 Parent(s): 056c529

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -10
app.py CHANGED
@@ -11,9 +11,7 @@ import torch
11
  import re
12
  import sys
13
  import soundfile as sf
14
- from utils import SpeechRecognition
15
- sp = SpeechRecognition()
16
- sp.load_model()
17
 
18
 
19
 
@@ -87,7 +85,7 @@ def predict_lang_specific(data,lang_code):
87
 
88
  return decoded_results
89
 
90
- def recognition(audio_file):
91
  print("audio_file", audio_file.name)
92
  speech, rate = sp.load_speech_with_file(audio_file.name)
93
 
@@ -95,7 +93,7 @@ def recognition(audio_file):
95
  print(result)
96
 
97
  return result
98
-
99
  #predict(load_file_to_data('audio file path',sampling_rate=16_000)) # beware of the audio file sampling rate
100
 
101
  #predict_lang_specific(load_file_to_data('audio file path',sampling_rate=16_000),'en') # beware of the audio file sampling rate
@@ -115,11 +113,11 @@ with gr.Blocks() as demo:
115
  ]
116
  output_transcribe1 = gr.Textbox(label="output")
117
  transcribe_audio1= gr.Button("Submit")
118
- with gr.Tab("Auto1"):
119
  gr.Markdown("automatically detects your language")
120
  inputs_speech2 = gr.Audio(label="Input Audio", type="file")
121
  output_transcribe2 = gr.Textbox()
122
- transcribe_audio2= gr.Button("Submit")
123
  transcribe_audio.click(fn=predict,
124
  inputs=inputs_speech,
125
  outputs=output_transcribe)
@@ -128,10 +126,9 @@ with gr.Blocks() as demo:
128
  inputs=inputs_speech1 ,
129
  outputs=output_transcribe1 )
130
 
131
- transcribe_audio2.click(fn=recognition,
132
  inputs=inputs_speech2 ,
133
- outputs=output_transcribe2 )
134
-
135
 
136
 
137
  if __name__ == "__main__":
 
11
  import re
12
  import sys
13
  import soundfile as sf
14
+
 
 
15
 
16
 
17
 
 
85
 
86
  return decoded_results
87
 
88
+ '''def recognition(audio_file):
89
  print("audio_file", audio_file.name)
90
  speech, rate = sp.load_speech_with_file(audio_file.name)
91
 
 
93
  print(result)
94
 
95
  return result
96
+ '''
97
  #predict(load_file_to_data('audio file path',sampling_rate=16_000)) # beware of the audio file sampling rate
98
 
99
  #predict_lang_specific(load_file_to_data('audio file path',sampling_rate=16_000),'en') # beware of the audio file sampling rate
 
113
  ]
114
  output_transcribe1 = gr.Textbox(label="output")
115
  transcribe_audio1= gr.Button("Submit")
116
+ '''with gr.Tab("Auto1"):
117
  gr.Markdown("automatically detects your language")
118
  inputs_speech2 = gr.Audio(label="Input Audio", type="file")
119
  output_transcribe2 = gr.Textbox()
120
+ transcribe_audio2= gr.Button("Submit")'''
121
  transcribe_audio.click(fn=predict,
122
  inputs=inputs_speech,
123
  outputs=output_transcribe)
 
126
  inputs=inputs_speech1 ,
127
  outputs=output_transcribe1 )
128
 
129
+ '''transcribe_audio2.click(fn=recognition,
130
  inputs=inputs_speech2 ,
131
+ outputs=output_transcribe2 )'''
 
132
 
133
 
134
  if __name__ == "__main__":