NeerAbhy commited on
Commit
27f27c7
1 Parent(s): 6f8dae7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -2,6 +2,14 @@ import gradio as gr
2
  import torch
3
  from transformers import pipeline
4
  from transformers import M2M100Tokenizer, M2M100ForConditionalGeneration
 
 
 
 
 
 
 
 
5
 
6
  pretrained_model: str = "facebook/m2m100_1.2B"
7
  cache_dir: str = "models/"
@@ -148,7 +156,6 @@ with demo:
148
  audio = gr.Audio(type="filepath", label = "Upload a file")
149
  text0 = gr.Textbox()
150
  text = gr.Textbox()
151
- text2 = gr.Textbox()
152
  source_lang = gr.Dropdown(label="Source lang", choices=list(lang_id.keys()), value=list(lang_id.keys())[0])
153
  target_lang = gr.Dropdown(label="target lang", choices=list(lang_id.keys()), value=list(lang_id.keys())[0])
154
 
@@ -157,10 +164,10 @@ with demo:
157
  # source_lang])
158
  b1 = gr.Button("convert to text")
159
  b3 = gr.Button("translate")
160
- b3.click(translation_text, inputs = [source_lang, target_lang, text0], outputs = text2)
161
  b1.click(audio_a_text, inputs=audio, outputs=text)
162
 
163
- b2 = gr.Button("Classification of speech")
164
- b2.click(print_s, inputs= [source_lang,target_lang, text0], outputs=text)
165
 
166
  demo.launch()
 
2
  import torch
3
  from transformers import pipeline
4
  from transformers import M2M100Tokenizer, M2M100ForConditionalGeneration
5
+ import fasttext
6
+ from huggingface_hub import hf_hub_download
7
+
8
+
9
+ model_path = hf_hub_download(repo_id="cis-lmu/glotlid", filename="model.bin")
10
+ identification_model = fasttext.load_model(model_path)
11
+ def lang_ident(text):
12
+ return indetification_model.predict(text)
13
 
14
  pretrained_model: str = "facebook/m2m100_1.2B"
15
  cache_dir: str = "models/"
 
156
  audio = gr.Audio(type="filepath", label = "Upload a file")
157
  text0 = gr.Textbox()
158
  text = gr.Textbox()
 
159
  source_lang = gr.Dropdown(label="Source lang", choices=list(lang_id.keys()), value=list(lang_id.keys())[0])
160
  target_lang = gr.Dropdown(label="target lang", choices=list(lang_id.keys()), value=list(lang_id.keys())[0])
161
 
 
164
  # source_lang])
165
  b1 = gr.Button("convert to text")
166
  b3 = gr.Button("translate")
167
+ b3.click(translation_text, inputs = [source_lang, target_lang, text0], outputs = text)
168
  b1.click(audio_a_text, inputs=audio, outputs=text)
169
 
170
+ b2 = gr.Button("Classification of language")
171
+ b2.click(lang_ident,inputs = text0, outputs=text)
172
 
173
  demo.launch()