wq2012 commited on
Commit
689d594
·
verified ·
1 Parent(s): bdfbc30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -4
app.py CHANGED
@@ -1,7 +1,34 @@
1
  import gradio as gr
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import os
3
+ from sidlingvo import wav_to_lang
4
+ from huggingface_hub import hf_hub_download
5
 
6
+ title = "Spoken Language Identification"
 
7
 
8
+ description = """
9
+ A demo of conformer-based spoken language identification. Paper: https://arxiv.org/abs/2202.12163
10
+ """
11
+
12
+ repo_id = "tflite-hub/conformer-lang-id"
13
+ model_path = "models"
14
+ hf_hub_download(repo_id=repo_id, filename="vad_short_model.tflite", local_dir=model_path)
15
+ hf_hub_download(repo_id=repo_id, filename="vad_short_mean_stddev.csv", local_dir=model_path)
16
+ hf_hub_download(repo_id=repo_id, filename="conformer_langid_medium.tflite", local_dir=model_path)
17
+
18
+ runner = wav_to_lang.WavToLangRunner(
19
+ vad_model_file=os.path.join(model_path, "vad_short_model.tflite"),
20
+ vad_mean_stddev_file=os.path.join(model_path, "vad_short_mean_stddev.csv"),
21
+ langid_model_file=os.path.join(model_path, "conformer_langid_medium.tflite"))
22
+
23
+ def predict(wav_file):
24
+ top_lang, _ = runner.wav_to_lang(wav_file)
25
+ return "Predicted language:" + top_lang
26
+
27
+ if __name__ == "__main__":
28
+ demo = gr.Interface(
29
+ fn=predict,
30
+ inputs=gr.Audio(type="filepath"),
31
+ outputs="text",
32
+ title=title,
33
+ description=description,)
34
+ demo.launch()