Jofthomas HF staff commited on
Commit
930024a
1 Parent(s): fcee6e6

Update TextGen/router.py

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