radinhas commited on
Commit
341f0bd
1 Parent(s): bd2d0db

Update apis/chat_api.py

Browse files
Files changed (1) hide show
  1. apis/chat_api.py +4 -8
apis/chat_api.py CHANGED
@@ -7,7 +7,7 @@ import random
7
  import base64
8
 
9
 
10
- from fastapi import FastAPI
11
  from fastapi.encoders import jsonable_encoder
12
  from fastapi.responses import JSONResponse
13
  from pydantic import BaseModel, Field
@@ -109,13 +109,9 @@ class ChatAPIApp:
109
  mp3_fp = BytesIO()
110
  #audioobj.save(fileName)
111
  audioobj.write_to_fp(mp3_fp)
112
- buffer = bytearray(mp3_fp.read())
113
- base64EncodedStr = base64.encodebytes(buffer)
114
- item_response = {
115
- "src": mp3_fp
116
- }
117
- json_compatible_item_data = jsonable_encoder(item_response)
118
- return JSONResponse(content=json_compatible_item_data)
119
 
120
  def setup_routes(self):
121
  for prefix in ["", "/v1"]:
 
7
  import base64
8
 
9
 
10
+ from fastapi import FastAPI, Response
11
  from fastapi.encoders import jsonable_encoder
12
  from fastapi.responses import JSONResponse
13
  from pydantic import BaseModel, Field
 
109
  mp3_fp = BytesIO()
110
  #audioobj.save(fileName)
111
  audioobj.write_to_fp(mp3_fp)
112
+ #buffer = bytearray(mp3_fp.read())
113
+ #base64EncodedStr = base64.encodebytes(buffer)
114
+ return Response(content=mp3_fp, media_type="audio/mpeg")
 
 
 
 
115
 
116
  def setup_routes(self):
117
  for prefix in ["", "/v1"]: