@app.post("/api/xtts_stream")
def gpt_xtts_stream(inputs: xtts_stream_inputs):
try:
speaker["text"] = inputs.text
speaker['language'] = inputs.language
speaker['stream_chunk_size'] = inputs.stream_chunk_size
res = requests.post(
f"http://0.0.0.0:8004/tts_stream",
json=speaker,
stream=True,
)
def iterms_gene(res):
if res.status_code != 200:
print("Error:", res.text)
sys.exit(1)
first = True
for chunk in res.iter_content(chunk_size=512):
if first:
first = False
if chunk:
yield chunk
# 返回音频流文件
return StreamingResponse(iterms_gene(res), media_type="audio/wav")
except Exception as e:
logging.error(f"Error: {e}")
return {"error": str(e)}
i want to use main.py in /tts_stream, so up.
but, i get down error:
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/responses.py", line 259, in call
await wrap(partial(self.listen_for_disconnect, receive))
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/responses.py", line 255, in wrap
await func()
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/responses.py", line 232, in listen_for_disconnect
message = await receive()
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 538, in receive
await self.message_event.wait()
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/asyncio/locks.py", line 226, in wait
await fut
asyncio.exceptions.CancelledError: Cancelled by cancel scope 7ff72233f610
During handling of the above exception, another exception occurred:
Exception Group Traceback (most recent call last):
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in call
return await self.app(scope, receive, send)
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/fastapi/applications.py", line 1054, in call
await super().call(scope, receive, send)
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/applications.py", line 116, in call
await self.middleware_stack(scope, receive, send)
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/middleware/errors.py", line 186, in call
raise exc
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/middleware/errors.py", line 164, in call
await self.app(scope, receive, _send)
File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 62, in call
ERROR: Exception in ASGI application Traceback (most recent call last): File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/responses.py", line 259, in call await wrap(partial(self.listen_for_disconnect, receive)) File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/responses.py", line 255, in wrap await func() File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/starlette/responses.py", line 232, in listen_for_disconnect message = await receive() File "/home/search/miniconda3/envs/XTTS/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 538, in receive await self.message_event.wait() File "/home/search/miniconda3/envs/XTTS/lib/python3.9/asyncio/locks.py", line 226, in wait await fut asyncio.exceptions.CancelledError: Cancelled by cancel scope 7ff72233f610
During handling of the above exception, another exception occurred:
TORCH_USE_CUDA_DSA
to enable device-side assertions.+------------------------------------
main.py don`t change!