Update TextGen/router.py
Browse files- TextGen/router.py +24 -24
TextGen/router.py
CHANGED
@@ -63,7 +63,7 @@ song_base_api=os.environ["VERCEL_API"]
|
|
63 |
|
64 |
my_hf_token=os.environ["HF_TOKEN"]
|
65 |
|
66 |
-
tts_client = Client("Jofthomas/xtts",hf_token=my_hf_token)
|
67 |
|
68 |
main_npcs={
|
69 |
"Blacksmith":"./voices/Blacksmith.mp3",
|
@@ -143,33 +143,33 @@ def determine_vocie_from_npc(npc,genre):
|
|
143 |
|
144 |
@app.post("/generate_wav")
|
145 |
async def generate_wav(message: VoiceMessage):
|
146 |
-
try:
|
147 |
-
voice = determine_vocie_from_npc(message.npc, message.genre)
|
148 |
-
audio_file_pth = handle_file(voice)
|
149 |
-
|
150 |
# Generator function to yield audio chunks
|
151 |
-
async def audio_stream():
|
152 |
-
result = tts_client.predict(
|
153 |
-
prompt=message.input,
|
154 |
-
language=message.language,
|
155 |
-
audio_file_pth=audio_file_pth,
|
156 |
-
mic_file_path=None,
|
157 |
-
use_mic=False,
|
158 |
-
voice_cleanup=False,
|
159 |
-
no_lang_auto_detect=False,
|
160 |
-
agree=True,
|
161 |
-
api_name="/predict"
|
162 |
-
)
|
163 |
-
for sampling_rate, audio_chunk in result:
|
164 |
-
yield audio_chunk.tobytes()
|
165 |
-
await asyncio.sleep(0) # Yield control to the event loop
|
166 |
|
167 |
# Return the generated audio as a streaming response
|
168 |
-
|
169 |
-
|
170 |
-
except Exception as e:
|
171 |
-
raise HTTPException(status_code=500, detail=str(e))
|
172 |
|
|
|
|
|
|
|
173 |
|
174 |
|
175 |
@app.get("/generate_voice_eleven", response_class=StreamingResponse)
|
|
|
63 |
|
64 |
my_hf_token=os.environ["HF_TOKEN"]
|
65 |
|
66 |
+
#tts_client = Client("Jofthomas/xtts",hf_token=my_hf_token)
|
67 |
|
68 |
main_npcs={
|
69 |
"Blacksmith":"./voices/Blacksmith.mp3",
|
|
|
143 |
|
144 |
@app.post("/generate_wav")
|
145 |
async def generate_wav(message: VoiceMessage):
|
146 |
+
# try:
|
147 |
+
# voice = determine_vocie_from_npc(message.npc, message.genre)
|
148 |
+
# audio_file_pth = handle_file(voice)
|
149 |
+
#
|
150 |
# Generator function to yield audio chunks
|
151 |
+
# async def audio_stream():
|
152 |
+
# result = tts_client.predict(
|
153 |
+
# prompt=message.input,
|
154 |
+
# language=message.language,
|
155 |
+
# audio_file_pth=audio_file_pth,
|
156 |
+
# mic_file_path=None,
|
157 |
+
# use_mic=False,
|
158 |
+
# voice_cleanup=False,
|
159 |
+
# no_lang_auto_detect=False,
|
160 |
+
# agree=True,
|
161 |
+
# api_name="/predict"
|
162 |
+
# )
|
163 |
+
# for sampling_rate, audio_chunk in result:
|
164 |
+
# yield audio_chunk.tobytes()
|
165 |
+
# await asyncio.sleep(0) # Yield control to the event loop
|
166 |
|
167 |
# Return the generated audio as a streaming response
|
168 |
+
# return StreamingResponse(audio_stream(), media_type="audio/wav")
|
|
|
|
|
|
|
169 |
|
170 |
+
# except Exception as e:
|
171 |
+
# raise HTTPException(status_code=500, detail=str(e))
|
172 |
+
return 200
|
173 |
|
174 |
|
175 |
@app.get("/generate_voice_eleven", response_class=StreamingResponse)
|