Ahsen Khaliq commited on
Commit
d6a2d06
1 Parent(s): e8f9c74

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -11,23 +11,7 @@ import matplotlib.pyplot as plt
11
  import gradio as gr
12
 
13
 
14
-
15
- def inference(audio)
16
- speech, rate = soundfile.read(audio.name)
17
- assert rate == fs, "mismatch in sampling rate"
18
- nbests = speech2text(speech)
19
- text, *_ = nbests[0]
20
-
21
- print(f"Input Speech: {file_name}")
22
- display(Audio(speech, rate=rate))
23
- librosa.display.waveplot(speech, sr=rate)
24
- plt.show()
25
- print(f"ASR hypothesis: {text_normalizer(text)}")
26
- print("*" * 50)
27
-
28
-
29
  d = ModelDownloader()
30
- # It may takes a while to download and build models
31
  speech2text = Speech2Text(
32
  **d.download_and_unpack(tag),
33
  device="cpu",
@@ -45,4 +29,20 @@ def text_normalizer(text):
45
 
46
  lang = 'multilingual'
47
  fs = 16000
48
- tag = 'ftshijt/open_li52_asr_train_asr_raw_bpe7000_valid.acc.ave_10best'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  import gradio as gr
12
 
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  d = ModelDownloader()
 
15
  speech2text = Speech2Text(
16
  **d.download_and_unpack(tag),
17
  device="cpu",
 
29
 
30
  lang = 'multilingual'
31
  fs = 16000
32
+ tag = 'ftshijt/open_li52_asr_train_asr_raw_bpe7000_valid.acc.ave_10best'
33
+
34
+
35
+ def inference(audio):
36
+ speech, rate = soundfile.read(audio.name)
37
+ assert rate == fs, "mismatch in sampling rate"
38
+ nbests = speech2text(speech)
39
+ text, *_ = nbests[0]
40
+
41
+ print(f"Input Speech: {file_name}")
42
+ display(Audio(speech, rate=rate))
43
+ librosa.display.waveplot(speech, sr=rate)
44
+ plt.show()
45
+ print(f"ASR hypothesis: {text_normalizer(text)}")
46
+ print("*" * 50)
47
+
48
+