aiplexdeveloper commited on
Commit
9b9cb9f
·
verified ·
1 Parent(s): 8ab7180

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +5 -4
handler.py CHANGED
@@ -24,9 +24,7 @@ class EndpointHandler:
24
 
25
  AUDIO_PROMPT_PATH=hf_hub_download(repo_id="aiplexdeveloper/chatterbox", filename="arjun_das_output_audio.mp3")
26
  wav = self.model.generate(text, audio_prompt_path=AUDIO_PROMPT_PATH, exaggeration = exaggeration, cfg_weight=cfg_weight)
27
-
28
- # ta.save("test-2.wav", wav, self.model.sr)
29
- # Convert the tensor to numpy and write to an in-memory buffer
30
  buffer = io.BytesIO()
31
  sf.write(buffer, wav.cpu().numpy().T, self.model.sr, format='WAV')
32
  buffer.seek(0)
@@ -34,7 +32,10 @@ class EndpointHandler:
34
  # Encode to base64
35
  audio_base64 = base64.b64encode(buffer.read()).decode('utf-8')
36
 
37
- return [{"audio_base64": audio_base64}]
 
 
 
38
 
39
 
40
  except Exception as e:
 
24
 
25
  AUDIO_PROMPT_PATH=hf_hub_download(repo_id="aiplexdeveloper/chatterbox", filename="arjun_das_output_audio.mp3")
26
  wav = self.model.generate(text, audio_prompt_path=AUDIO_PROMPT_PATH, exaggeration = exaggeration, cfg_weight=cfg_weight)
27
+
 
 
28
  buffer = io.BytesIO()
29
  sf.write(buffer, wav.cpu().numpy().T, self.model.sr, format='WAV')
30
  buffer.seek(0)
 
32
  # Encode to base64
33
  audio_base64 = base64.b64encode(buffer.read()).decode('utf-8')
34
 
35
+ audio_length_seconds = len(wav) / self.model.sr
36
+
37
+
38
+ return [{"audio_base64": audio_base64, "audio_length_seconds":audio_length_seconds}]
39
 
40
 
41
  except Exception as e: