datnth1709 commited on
Commit
ad6ff47
·
1 Parent(s): e00f0bb

update speech2text module

Browse files
Files changed (2) hide show
  1. app.py +10 -10
  2. requirements.txt +2 -0
app.py CHANGED
@@ -106,16 +106,16 @@ with gr.Blocks() as demo:
106
  gr.Examples(examples=vi_example_text,
107
  inputs=[vietnamese])
108
  with gr.TabItem("Speech2text and translation"):
109
- inputs = gr.inputs.Audio(label="Input Audio", type="file")
110
- outputs = gr.outputs.Textbox(label="Output Text")
111
- title = "Speech to text and translate Vietnamese to English"
112
- description = "Gradio demo for a wav2vec2-base-vietnamese-250h and Helsinki-NLP/opus-mt-vi-en"
113
- gr.Interface(inference,
114
- inputs,
115
- outputs,
116
- title=title,
117
- description=description,
118
- examples=vi_example_voice)
119
 
120
  if __name__ == "__main__":
121
  demo.launch()
 
106
  gr.Examples(examples=vi_example_text,
107
  inputs=[vietnamese])
108
  with gr.TabItem("Speech2text and translation"):
109
+ with gr.Row():
110
+ with gr.Column():
111
+ audio = gr.Audio(source="microphone", label="Input Audio", type="filepath")
112
+ translate_button = gr.Button(value="Translate To English")
113
+ with gr.Column():
114
+ enlish = gr.Textbox(label="English Text")
115
+
116
+ translate_button.click(lambda voice: inference(voice), inputs=audio, outputs=english)
117
+ gr.Examples(examples=vi_example_voice,
118
+ inputs=[audio])
119
 
120
  if __name__ == "__main__":
121
  demo.launch()
requirements.txt CHANGED
@@ -5,6 +5,8 @@ datasets==1.11.0
5
  pyctcdecode==v0.1.0
6
  speechbrain
7
  pydub
 
 
8
  soundfile
9
  ffmpeg-python
10
  gradio
 
5
  pyctcdecode==v0.1.0
6
  speechbrain
7
  pydub
8
+ kenlm
9
+ pyctcdecode
10
  soundfile
11
  ffmpeg-python
12
  gradio