Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,9 @@ from huggingface_hub import hf_hub_download
|
|
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 |
-
|
|
|
|
|
13 |
|
14 |
pretrained_model: str = "facebook/m2m100_1.2B"
|
15 |
cache_dir: str = "models/"
|
@@ -23,6 +25,18 @@ clasification = pipeline(
|
|
23 |
"audio-classification",
|
24 |
model="anton-l/xtreme_s_xlsr_300m_minds14",
|
25 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
def audio_a_text(audio):
|
28 |
text = transcription(audio)["text"]
|
|
|
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 |
+
label, array = identification_model.predict(text)
|
13 |
+
label = get_name(label[0])
|
14 |
+
return {language : label[0], socore : array[0]}
|
15 |
|
16 |
pretrained_model: str = "facebook/m2m100_1.2B"
|
17 |
cache_dir: str = "models/"
|
|
|
25 |
"audio-classification",
|
26 |
model="anton-l/xtreme_s_xlsr_300m_minds14",
|
27 |
)
|
28 |
+
def language_names(json_path):
|
29 |
+
with open(json_path, 'r') as json_file:
|
30 |
+
data = json.load(json_file)
|
31 |
+
return data
|
32 |
+
|
33 |
+
label2name = language_names("assetslanguage_names.json")
|
34 |
+
|
35 |
+
def get_name(label):
|
36 |
+
"""Get the name of language from label"""
|
37 |
+
iso_3 = label.split('_')[0]
|
38 |
+
name = label2name[iso_3]
|
39 |
+
return name
|
40 |
|
41 |
def audio_a_text(audio):
|
42 |
text = transcription(audio)["text"]
|