Upload tts-server.py
Browse files- tts-server.py +23 -0
tts-server.py
CHANGED
|
@@ -402,6 +402,29 @@ async def check_speech_endpoint():
|
|
| 402 |
"""
|
| 403 |
return {"status": "ok", "message": "Speech endpoint is ready"}
|
| 404 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 405 |
@app.post("/v1/audio/speech")
|
| 406 |
async def create_speech(req: OpenAIRequest):
|
| 407 |
"""
|
|
|
|
| 402 |
"""
|
| 403 |
return {"status": "ok", "message": "Speech endpoint is ready"}
|
| 404 |
|
| 405 |
+
@app.get("/v1/audio/speech/stream")
|
| 406 |
+
async def stream_speech_get(
|
| 407 |
+
input: str,
|
| 408 |
+
voice: str,
|
| 409 |
+
speed: float = 1.0,
|
| 410 |
+
pitch: float = 0.0,
|
| 411 |
+
response_format: str = "aac"
|
| 412 |
+
):
|
| 413 |
+
"""
|
| 414 |
+
GET endpoint for direct streaming (e.g. for <audio src="...">).
|
| 415 |
+
"""
|
| 416 |
+
if not input:
|
| 417 |
+
raise HTTPException(status_code=400, detail="Input text is required")
|
| 418 |
+
|
| 419 |
+
media_type = "audio/aac"
|
| 420 |
+
if response_format == "mp3":
|
| 421 |
+
media_type = "audio/mpeg"
|
| 422 |
+
|
| 423 |
+
return StreamingResponse(
|
| 424 |
+
engine.stream_audio(input, voice, speed, pitch),
|
| 425 |
+
media_type=media_type
|
| 426 |
+
)
|
| 427 |
+
|
| 428 |
@app.post("/v1/audio/speech")
|
| 429 |
async def create_speech(req: OpenAIRequest):
|
| 430 |
"""
|