fixed
Browse files- App/TTS/TTSRoutes.py +9 -6
- requirements.txt +1 -0
App/TTS/TTSRoutes.py
CHANGED
@@ -21,6 +21,7 @@ import asyncio
|
|
21 |
from fastapi import FastAPI, Request, HTTPException
|
22 |
from fastapi.responses import StreamingResponse, FileResponse
|
23 |
import os
|
|
|
24 |
|
25 |
tts_router = APIRouter(tags=["TTS"])
|
26 |
data = {"username": os.environ.get("USERNAME"), "password": os.environ.get("PASSWORD")}
|
@@ -128,9 +129,11 @@ async def serve_audio(request: Request, audio_name: str):
|
|
128 |
return FileResponse(audio_path, media_type="audio/mpeg")
|
129 |
|
130 |
|
131 |
-
def read_file_range(path, start, end):
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
|
|
|
|
|
21 |
from fastapi import FastAPI, Request, HTTPException
|
22 |
from fastapi.responses import StreamingResponse, FileResponse
|
23 |
import os
|
24 |
+
import aiofiles
|
25 |
|
26 |
tts_router = APIRouter(tags=["TTS"])
|
27 |
data = {"username": os.environ.get("USERNAME"), "password": os.environ.get("PASSWORD")}
|
|
|
129 |
return FileResponse(audio_path, media_type="audio/mpeg")
|
130 |
|
131 |
|
132 |
+
async def read_file_range(path, start, end):
|
133 |
+
async with aiofiles.open(path, "rb") as file:
|
134 |
+
await file.seek(start)
|
135 |
+
while True:
|
136 |
+
data = await file.read(1024 * 1024) # read in chunks of 1MB
|
137 |
+
if not data or await file.tell() > end:
|
138 |
+
break
|
139 |
+
yield data
|
requirements.txt
CHANGED
@@ -23,6 +23,7 @@ requests
|
|
23 |
bs4
|
24 |
strenum
|
25 |
pydub
|
|
|
26 |
|
27 |
|
28 |
git+https://github.com/snowby666/poe-api-wrapper.git@2c91207598ad930901cb9fb09734705056b7b6a9
|
|
|
23 |
bs4
|
24 |
strenum
|
25 |
pydub
|
26 |
+
aiofiles
|
27 |
|
28 |
|
29 |
git+https://github.com/snowby666/poe-api-wrapper.git@2c91207598ad930901cb9fb09734705056b7b6a9
|