Jofthomas HF staff commited on
Commit
0345f82
1 Parent(s): a02cfd8

Update TextGen/router.py

Browse files
Files changed (1) hide show
  1. TextGen/router.py +5 -5
TextGen/router.py CHANGED
@@ -17,11 +17,11 @@ from langchain_google_genai import (
17
  from TextGen import app
18
  from gradio_client import Client, handle_file
19
  from typing import List
20
- from elevenlabs.client import AsyncElevenLabs
21
  from elevenlabs import stream
22
 
23
 
24
- Eleven_client = AsyncElevenLabs(
25
  api_key=os.environ["ELEVEN_API_KEY"], # Defaults to ELEVEN_API_KEY
26
  )
27
 
@@ -167,9 +167,9 @@ async def generate_wav(message: VoiceMessage):
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")
 
17
  from TextGen import app
18
  from gradio_client import Client, handle_file
19
  from typing import List
20
+ from elevenlabs.client import ElevenLabs
21
  from elevenlabs import stream
22
 
23
 
24
+ Eleven_client = ElevenLabs(
25
  api_key=os.environ["ELEVEN_API_KEY"], # Defaults to ELEVEN_API_KEY
26
  )
27
 
 
167
  except Exception as e:
168
  raise HTTPException(status_code=500, detail=str(e))
169
  @app.post("/generate_voice")
170
+ def generate_voice(message: VoiceMessage):
171
+ def audio_stream():
172
+ for chunk in Eleven_client.generate(text=message.input, stream=True):
173
  yield chunk
174
 
175
  return StreamingResponse(audio_stream(), media_type="audio/wav")