mds04 commited on
Commit
efe17d8
·
verified ·
1 Parent(s): 7b5675b

Upload 5 files

Browse files
Files changed (5) hide show
  1. app.py +13 -0
  2. inference.py +17 -0
  3. label_map.json +1 -0
  4. polar_lid_classifier.pkl +3 -0
  5. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from inference import predict
3
+
4
+ def predict_from_audio(audio):
5
+ return predict(audio)["language"]
6
+
7
+ demo = gr.Interface(
8
+ fn=predict_from_audio,
9
+ inputs=gr.Audio(type="filepath"),
10
+ outputs="label",
11
+ title="Custom Language Identifier",
12
+ description="Upload audio → detects English, Mandarin, Tamil, Malay, Iban, Bukar Sadong"
13
+ )
inference.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch, joblib, json
2
+ from speechbrain.pretrained import EncoderClassifier
3
+ from your_module import Config, AudioProcessor, LanguageIdentifier
4
+
5
+ # Load classifier + config
6
+ custom_classifier = joblib.load("polar_lid_classifier.pkl")
7
+ label_map = json.load(open("label_map.json"))
8
+
9
+ config = Config()
10
+ config.label_map = label_map
11
+
12
+ identifier = LanguageIdentifier(config)
13
+ identifier.load_vox_model()
14
+ identifier.custom_classifier = custom_classifier
15
+
16
+ def predict(audio_path: str):
17
+ return identifier.predict(audio_path)
label_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"iban": 0, "bukar_sadong": 1, "malay": 2}
polar_lid_classifier.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c7237502bf2f5a7d5cdde1b450445ace9a3e20230bf2358053ea83bb2325fe7e
3
+ size 7055
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ torch
2
+ speechbrain
3
+ scikit-learn
4
+ joblib
5
+ gradio