selectmixer commited on
Commit
a240179
·
1 Parent(s): 42c394e

handler change1

Browse files
Files changed (1) hide show
  1. handler.py +7 -4
handler.py CHANGED
@@ -28,12 +28,15 @@ class EndpointHandler:
28
  self.model.set_generation_params(duration=duration)
29
  outputs = self.model.generate(inputs)
30
 
31
- # Save each generated audio file with loudness normalization
32
  output_files = []
33
  for idx, one_wav in enumerate(outputs):
34
  output_file_path = f"generated_audio_{idx}.wav"
35
  audio_write(output_file_path, one_wav.cpu(), self.model.sample_rate, strategy="loudness", loudness_compressor=True)
36
- output_files.append(output_file_path)
 
 
 
 
37
 
38
- return {"generated_audio_files": output_files}
39
-
 
28
  self.model.set_generation_params(duration=duration)
29
  outputs = self.model.generate(inputs)
30
 
31
+ # Save each generated audio file with loudness normalization and encode in base64
32
  output_files = []
33
  for idx, one_wav in enumerate(outputs):
34
  output_file_path = f"generated_audio_{idx}.wav"
35
  audio_write(output_file_path, one_wav.cpu(), self.model.sample_rate, strategy="loudness", loudness_compressor=True)
36
+
37
+ # Read the file and encode it in base64
38
+ with open(output_file_path, "rb") as audio_file:
39
+ encoded_string = base64.b64encode(audio_file.read()).decode('utf-8')
40
+ output_files.append(encoded_string)
41
 
42
+ return {"generated_audio_files": output_files}