datnth1709 commited on
Commit
530a947
·
1 Parent(s): e8eafba

update library

Browse files
Files changed (2) hide show
  1. app.py +12 -3
  2. requirements.txt +5 -3
app.py CHANGED
@@ -75,7 +75,6 @@ def speech2text(audio):
75
  return beam_search_output
76
 
77
 
78
-
79
  """Machine translation"""
80
  model_checkpoint = "huynguyen208/fantastic4-finetuned-vi-to-en-PhoMT-demo"
81
  translator = pipeline("translation", model=model_checkpoint)
@@ -88,15 +87,25 @@ def inference(audio):
88
  en_text = translate(vi_text)
89
  return en_text
90
 
 
 
 
 
 
 
 
 
 
 
91
  inputs = gr.inputs.Audio(label="Input Audio", type="file")
92
  outputs = gr.outputs.Textbox(label="Output Text")
93
  title = "Speech to text and translate Vietnamese to English"
94
  description = "Gradio demo for a wav2vec2-base-vietnamese-250h and Helsinki-NLP/opus-mt-vi-en"
95
  examples=[['vi_speech_01.wav'], ['vi_speech_02.wav'], ['vi_speech_03.wav']]
96
- iface = gr.Interface(inference,
97
  inputs,
98
  outputs,
99
  title=title,
100
  description=description,
101
  examples=examples)
102
- iface.launch()
 
75
  return beam_search_output
76
 
77
 
 
78
  """Machine translation"""
79
  model_checkpoint = "huynguyen208/fantastic4-finetuned-vi-to-en-PhoMT-demo"
80
  translator = pipeline("translation", model=model_checkpoint)
 
87
  en_text = translate(vi_text)
88
  return en_text
89
 
90
+
91
+ """Gradio demo"""
92
+ iface1 = gr.Interface(fn=translate,
93
+ inputs=["text"],
94
+ outputs="text",
95
+ title = 'Translate Vietnamese to English',
96
+ description = 'Mini Translator')
97
+ iface1.launch(inline = False)
98
+
99
+
100
  inputs = gr.inputs.Audio(label="Input Audio", type="file")
101
  outputs = gr.outputs.Textbox(label="Output Text")
102
  title = "Speech to text and translate Vietnamese to English"
103
  description = "Gradio demo for a wav2vec2-base-vietnamese-250h and Helsinki-NLP/opus-mt-vi-en"
104
  examples=[['vi_speech_01.wav'], ['vi_speech_02.wav'], ['vi_speech_03.wav']]
105
+ iface2 = gr.Interface(inference,
106
  inputs,
107
  outputs,
108
  title=title,
109
  description=description,
110
  examples=examples)
111
+ iface2.launch()
requirements.txt CHANGED
@@ -1,8 +1,10 @@
1
- torch
2
- torchaudio
 
 
 
3
  speechbrain
4
  pydub
5
- datasets
6
  soundfile
7
  ffmpeg-python
8
  gradio
 
1
+ torch==1.9.0
2
+ torchaudio==0.9.0
3
+ transformers==4.9.2
4
+ datasets==1.11.0
5
+ pyctcdecode==v0.1.0
6
  speechbrain
7
  pydub
 
8
  soundfile
9
  ffmpeg-python
10
  gradio