redfernstech commited on
Commit
217f0f3
·
verified ·
1 Parent(s): 93b75d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import os
 
2
  import time
3
  from fastapi import FastAPI, Request
4
  from fastapi.responses import HTMLResponse
@@ -180,7 +181,11 @@ async def chat(request: MessageRequest):
180
  "timestamp": datetime.datetime.now().isoformat()
181
  }
182
  chat_history.append(message_data)
183
- return {"response": response1}
 
 
 
 
184
 
185
  @app.get("/")
186
  def read_root(request: Request):
 
1
  import os
2
+ from gtts import gTTS
3
  import time
4
  from fastapi import FastAPI, Request
5
  from fastapi.responses import HTMLResponse
 
181
  "timestamp": datetime.datetime.now().isoformat()
182
  }
183
  chat_history.append(message_data)
184
+ tts = gTTS(text=response1, lang=language_code)
185
+ audio_path = "response.mp3"
186
+ tts.save(audio_path)
187
+ return {"response": response1,
188
+ "audioUrl": f"http://localhost:5000/audio/{audio_path}"}
189
 
190
  @app.get("/")
191
  def read_root(request: Request):