fix: /tts_stream als GET mit Query-Params (war 405 Method Not Allowed)
daswer123 xtts-api-server hat /tts_stream nur als GET: allow: GET → POST gab 405 → Request hing. Umstellung: - method: 'GET' - text/language/speaker_wav/stream_chunk_size als URLSearchParams im Query-String - kein body mehr (kein req.write, kein Content-Length) Ab jetzt echter streaming-Flow: Samples kommen waehrend XTTS noch rendert, time-to-first-audio ~300-500ms. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+11
-17
@@ -195,32 +195,27 @@ async function _runTTSRequest(payload) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ruft /tts_to_audio/ auf und streamt das Response-Body chunkweise an
|
||||
* den Callback. Kein echtes Server-Streaming (XTTS rendert komplett
|
||||
* bevor es antwortet), aber stabil und mit der Queue + grosszuegigem
|
||||
* AudioTrack-Buffer klingt's akzeptabel.
|
||||
* Ruft /tts_stream (GET) auf — echter Streaming-Endpoint bei daswer123.
|
||||
* Samples fliessen waehrend XTTS rendert (chunked transfer).
|
||||
* Time-to-first-audio ~300-500ms statt 2-4s beim batch-Endpoint.
|
||||
*
|
||||
* /tts_stream ist elegant, funktioniert aber nicht in allen Versionen
|
||||
* von daswer123/xtts-api-server.
|
||||
* Parameter werden als Query-String uebergeben (GET-API).
|
||||
*/
|
||||
function streamXTTSAsPCM(text, language, speakerWav, onPcmChunk) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const body = JSON.stringify({
|
||||
const qs = new URLSearchParams({
|
||||
text,
|
||||
language,
|
||||
speaker_wav: speakerWav || "",
|
||||
language: language || "de",
|
||||
speaker_wav: speakerWav ? speakerWav : "",
|
||||
stream_chunk_size: "40",
|
||||
});
|
||||
|
||||
const url = new URL(`${XTTS_API_URL}/tts_to_audio/`);
|
||||
const url = new URL(`${XTTS_API_URL}/tts_stream?${qs.toString()}`);
|
||||
const options = {
|
||||
hostname: url.hostname,
|
||||
port: url.port,
|
||||
path: url.pathname,
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Content-Length": Buffer.byteLength(body),
|
||||
},
|
||||
path: `${url.pathname}?${url.searchParams.toString()}`,
|
||||
method: "GET",
|
||||
timeout: 60000,
|
||||
};
|
||||
|
||||
@@ -282,7 +277,6 @@ function streamXTTSAsPCM(text, language, speakerWav, onPcmChunk) {
|
||||
|
||||
req.on("error", reject);
|
||||
req.on("timeout", () => { req.destroy(); reject(new Error("XTTS API Timeout (60s)")); });
|
||||
req.write(body);
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user