srd4 commited on
Commit
ef46aa8
·
verified ·
1 Parent(s): bc0028f

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +5 -1
handler.py CHANGED
@@ -1,5 +1,6 @@
1
  from typing import Dict
2
  from faster_whisper import WhisperModel
 
3
 
4
  class EndpointHandler:
5
  def __init__(self, model_dir=None):
@@ -11,8 +12,11 @@ class EndpointHandler:
11
  # Process the input data expected to be in 'inputs' key containing audio file bytes
12
  audio_bytes = data["inputs"]
13
 
 
 
 
14
  # Perform transcription using the model
15
- segments, info = self.model.transcribe(audio_bytes)
16
 
17
  # Compile the results into a text string and extract language information
18
  text = " ".join(segment.text for segment in segments)
 
1
  from typing import Dict
2
  from faster_whisper import WhisperModel
3
+ import io
4
 
5
  class EndpointHandler:
6
  def __init__(self, model_dir=None):
 
12
  # Process the input data expected to be in 'inputs' key containing audio file bytes
13
  audio_bytes = data["inputs"]
14
 
15
+ # Convert bytes to a file-like object
16
+ audio_file = io.BytesIO(audio_bytes)
17
+
18
  # Perform transcription using the model
19
+ segments, info = self.model.transcribe(audio_file)
20
 
21
  # Compile the results into a text string and extract language information
22
  text = " ".join(segment.text for segment in segments)