update handler.py
Browse files- handler.py +4 -0
handler.py
CHANGED
@@ -9,6 +9,7 @@ import torchaudio
|
|
9 |
from transformers import WhisperForAudioClassification, WhisperFeatureExtractor
|
10 |
from transformers.pipelines.audio_utils import ffmpeg_read
|
11 |
import numpy as np
|
|
|
12 |
|
13 |
class EndpointHandler():
|
14 |
"""
|
@@ -45,6 +46,9 @@ class EndpointHandler():
|
|
45 |
|
46 |
# step one, get the sampling rate of the audio
|
47 |
audio = data['audio']
|
|
|
|
|
|
|
48 |
|
49 |
fs = data['sampling_rate']
|
50 |
|
|
|
9 |
from transformers import WhisperForAudioClassification, WhisperFeatureExtractor
|
10 |
from transformers.pipelines.audio_utils import ffmpeg_read
|
11 |
import numpy as np
|
12 |
+
import base64
|
13 |
|
14 |
class EndpointHandler():
|
15 |
"""
|
|
|
46 |
|
47 |
# step one, get the sampling rate of the audio
|
48 |
audio = data['audio']
|
49 |
+
# we encoded using base64.b64encode(filebytes).decode('utf-8') to pass to api url
|
50 |
+
audio = base64.b64decode(audio.encode('utf-8'))
|
51 |
+
|
52 |
|
53 |
fs = data['sampling_rate']
|
54 |
|