Jofthomas HF staff commited on
Commit
087c393
1 Parent(s): 1b38d67

Update TextGen/router.py

Browse files
Files changed (1) hide show
  1. TextGen/router.py +5 -5
TextGen/router.py CHANGED
@@ -168,20 +168,20 @@ async def generate_wav(message: VoiceMessage):
168
  raise HTTPException(status_code=500, detail=str(e))
169
 
170
 
 
171
  @app.get("/generate_voice", response_class=StreamingResponse)
172
  @app.post("/generate_voice", response_class=StreamingResponse)
173
  def generate_voice(message: VoiceMessage = None):
174
- print("message",message)
175
  if message is None:
176
- message=Last_message
177
  else:
178
- Last_message=message
179
- def audio_stream():
180
 
 
181
  # Generate the audio stream from ElevenLabs
182
  for chunk in Eleven_client.generate(text=message.input, stream=True):
183
  yield chunk
184
-
185
 
186
  return StreamingResponse(audio_stream(), media_type="audio/mpeg")
187
 
 
168
  raise HTTPException(status_code=500, detail=str(e))
169
 
170
 
171
+
172
  @app.get("/generate_voice", response_class=StreamingResponse)
173
  @app.post("/generate_voice", response_class=StreamingResponse)
174
  def generate_voice(message: VoiceMessage = None):
175
+ global Last_message # Declare Last_message as global
176
  if message is None:
177
+ message = Last_message
178
  else:
179
+ Last_message = message
 
180
 
181
+ def audio_stream():
182
  # Generate the audio stream from ElevenLabs
183
  for chunk in Eleven_client.generate(text=message.input, stream=True):
184
  yield chunk
 
185
 
186
  return StreamingResponse(audio_stream(), media_type="audio/mpeg")
187