apenasissso commited on
Commit
9176a6a
1 Parent(s): 1ca74a2

updates handler.py

Browse files
Files changed (1) hide show
  1. 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
- inputs = data.pop("inputs",data)
14
 
15
- print('audio_url', inputs)
16
- logging.info(f'audio_url {inputs}')
17
 
18
- # check if date exists and if it is a holiday
19
- # run normal prediction
20
- output = self.model.classify_file(inputs)
21
- return {"prediction": output[1].exp()}
 
 
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