almncarlo commited on
Commit
a714726
1 Parent(s): eafa69e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -7,6 +7,7 @@ import tempfile
7
  import uuid
8
 
9
  import torch
 
10
 
11
  from nemo.collections.asr.models import ASRModel
12
  from nemo.collections.asr.parts.utils.streaming_utils import FrameBatchMultiTaskAED
@@ -221,6 +222,12 @@ def on_src_or_tgt_lang_change(src_lang_value, tgt_lang_value, pnc_value):
221
  )
222
  return src_lang, tgt_lang, pnc
223
 
 
 
 
 
 
 
224
 
225
  with gr.Blocks(
226
  title="NeMo Canary Model",
@@ -273,16 +280,28 @@ with gr.Blocks(
273
  )
274
 
275
  model_output_text_box = gr.Textbox(
276
- label="Model Output",
277
  elem_id="model_output_text_box",
278
  )
279
 
 
 
 
 
 
 
280
  go_button.click(
281
  fn=transcribe,
282
  inputs = [audio_file, src_lang, tgt_lang, pnc],
283
  outputs = [model_output_text_box]
284
  )
285
 
 
 
 
 
 
 
286
  # call on_src_or_tgt_lang_change whenever src_lang or tgt_lang dropdown menus are changed
287
  src_lang.change(
288
  fn=on_src_or_tgt_lang_change,
@@ -294,6 +313,8 @@ with gr.Blocks(
294
  inputs=[src_lang, tgt_lang, pnc],
295
  outputs=[src_lang, tgt_lang, pnc],
296
  )
 
 
297
 
298
 
299
  demo.queue()
 
7
  import uuid
8
 
9
  import torch
10
+ import transformers
11
 
12
  from nemo.collections.asr.models import ASRModel
13
  from nemo.collections.asr.parts.utils.streaming_utils import FrameBatchMultiTaskAED
 
222
  )
223
  return src_lang, tgt_lang, pnc
224
 
225
+ llm_pipeline = transformers.pipeline(
226
+ "text-generation",
227
+ model="meta-llama/Meta-Llama-3-8B",
228
+ model_kwargs={"torch_dtype": torch.bfloat16},
229
+ device_map="auto"
230
+ )
231
 
232
  with gr.Blocks(
233
  title="NeMo Canary Model",
 
280
  )
281
 
282
  model_output_text_box = gr.Textbox(
283
+ label="Transcribed Text",
284
  elem_id="model_output_text_box",
285
  )
286
 
287
+ llm_output_text_box = gr.Textbox(
288
+ label="MyAlexa's Answer",
289
+ elem_id="llm_output_text_box",
290
+ )
291
+
292
+
293
  go_button.click(
294
  fn=transcribe,
295
  inputs = [audio_file, src_lang, tgt_lang, pnc],
296
  outputs = [model_output_text_box]
297
  )
298
 
299
+ model_output_text_box.change(
300
+ fn=llm_pipeline.
301
+ inputs = [model_output_text_box.value],
302
+ outputs = [llm_output_text_box]
303
+ )
304
+
305
  # call on_src_or_tgt_lang_change whenever src_lang or tgt_lang dropdown menus are changed
306
  src_lang.change(
307
  fn=on_src_or_tgt_lang_change,
 
313
  inputs=[src_lang, tgt_lang, pnc],
314
  outputs=[src_lang, tgt_lang, pnc],
315
  )
316
+
317
+
318
 
319
 
320
  demo.queue()