spookyspaghetti commited on
Commit
179cc8d
1 Parent(s): 6947dfb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -1,15 +1,21 @@
1
  import gradio as gr
2
 
3
- #gr.Interface.load("models/nvidia/stt_en_citrinet_1024_gamma_0_25").launch()
4
  from nemo.collections.asr.models import ASRModel
5
  import torch
6
  if torch.cuda.is_available():
7
  device = torch.device(f'cuda:0')
8
  asr_model = ASRModel.from_pretrained(model_name='stt_en_citrinet_1024')
 
 
 
 
 
 
9
  def transcribe(audio):
10
  """Speech to text using Nvidia Nemo"""
11
  text = asr_model.transcribe(paths2audio_files=[audio])[0]
12
- correct = list(gf.correct(text, max_candidates = 1))[0]
13
- return text, correct
 
14
 
15
  gr.Interface(fn=transcribe).launch()
 
1
  import gradio as gr
2
 
 
3
  from nemo.collections.asr.models import ASRModel
4
  import torch
5
  if torch.cuda.is_available():
6
  device = torch.device(f'cuda:0')
7
  asr_model = ASRModel.from_pretrained(model_name='stt_en_citrinet_1024')
8
+
9
+ from happytransformer import HappyTextToText, TTSettings
10
+ happy_tt = HappyTextToText("T5", "vennify/t5-base-grammar-correction")
11
+ args = TTSettings(num_beams=5, min_length=1)
12
+
13
+
14
  def transcribe(audio):
15
  """Speech to text using Nvidia Nemo"""
16
  text = asr_model.transcribe(paths2audio_files=[audio])[0]
17
+ # Add the prefix "grammar: " before each input
18
+ correct = happy_tt.generate_text("grammar: " + text, args=args)
19
+ return text, correct.text
20
 
21
  gr.Interface(fn=transcribe).launch()