apenasissso
commited on
Commit
·
9176a6a
1
Parent(s):
1ca74a2
updates handler.py
Browse files- handler.py +8 -8
handler.py
CHANGED
@@ -6,17 +6,17 @@ from typing import Dict, List, Any
|
|
6 |
class EndpointHandler:
|
7 |
def __init__(self, path=""):
|
8 |
self.model = EncoderClassifier.from_hparams("speechbrain/lang-id-voxlingua107-ecapa")
|
9 |
-
print('model loaded')
|
10 |
logging.info('model loaded')
|
11 |
|
12 |
def __call__(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
logging.info(f'audio_url {inputs}')
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
22 |
|
|
|
6 |
class EndpointHandler:
|
7 |
def __init__(self, path=""):
|
8 |
self.model = EncoderClassifier.from_hparams("speechbrain/lang-id-voxlingua107-ecapa")
|
|
|
9 |
logging.info('model loaded')
|
10 |
|
11 |
def __call__(self, data: Dict[str, Any]) -> Dict[str, Any]:
|
12 |
+
audio_url = data.pop("audio_url",data)
|
13 |
|
14 |
+
logging.info(f'audio_url {audio_url}')
|
|
|
15 |
|
16 |
+
output = self.model.classify_file(audio_url)
|
17 |
+
|
18 |
+
return {
|
19 |
+
"prediction": float(output[1].exp()[0]),
|
20 |
+
"language": output[3][0],
|
21 |
+
}
|
22 |
|