Jofthomas HF staff commited on
Commit
789182c
1 Parent(s): af4ad80

Update TextGen/router.py

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