aiplexdeveloper commited on
Commit
3666dfa
·
verified ·
1 Parent(s): 448356f

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +11 -10
handler.py CHANGED
@@ -30,13 +30,14 @@ class EndpointHandler():
30
  buffer = io.BytesIO()
31
  sf.write(buffer, full_audio.numpy(), 24000, format='WAV')
32
  buffer.seek(0)
33
-
34
- from flask import Response
35
- return Response(
36
- buffer.read(),
37
- mimetype='audio/wav',
38
- headers={
39
- 'Content-Disposition': 'attachment; filename=output.wav',
40
- 'Content-Type': 'audio/wav'
41
- }
42
- )
 
 
30
  buffer = io.BytesIO()
31
  sf.write(buffer, full_audio.numpy(), 24000, format='WAV')
32
  buffer.seek(0)
33
+ audio_bytes = buffer.read()
34
+ audio_b64 = base64.b64encode(audio_bytes).decode("utf-8")
35
+ return {
36
+ "headers": {
37
+ "Content-Disposition": "attachment; filename=output.wav",
38
+ "Content-Type": "audio/wav"
39
+ },
40
+ "body": audio_bytes,
41
+ "statusCode": 200,
42
+ "isBase64Encoded": True # if binary, encode
43
+ }