Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9b5a35cb4a | |||
| 5ac1a0a522 |
+11
-17
@@ -195,32 +195,27 @@ async function _runTTSRequest(payload) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ruft /tts_stream auf — echter Streaming-Endpoint von daswer123.
|
* Ruft /tts_stream (GET) auf — echter Streaming-Endpoint bei daswer123.
|
||||||
* Chunked Transfer-Encoding: Samples kommen WAEHREND XTTS rendert,
|
* Samples fliessen waehrend XTTS rendert (chunked transfer).
|
||||||
* nicht erst am Ende. Time-to-first-audio ~300-500ms statt 2-3s.
|
* Time-to-first-audio ~300-500ms statt 2-4s beim batch-Endpoint.
|
||||||
*
|
*
|
||||||
* stream_chunk_size = Characters pro Render-Iteration.
|
* Parameter werden als Query-String uebergeben (GET-API).
|
||||||
* 40 = guter Kompromiss zwischen Schnellstart und GPU-Effizienz.
|
|
||||||
*/
|
*/
|
||||||
function streamXTTSAsPCM(text, language, speakerWav, onPcmChunk) {
|
function streamXTTSAsPCM(text, language, speakerWav, onPcmChunk) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const body = JSON.stringify({
|
const qs = new URLSearchParams({
|
||||||
text,
|
text,
|
||||||
language,
|
language: language || "de",
|
||||||
speaker_wav: speakerWav || "",
|
speaker_wav: speakerWav ? speakerWav : "",
|
||||||
stream_chunk_size: 40,
|
stream_chunk_size: "40",
|
||||||
});
|
});
|
||||||
|
|
||||||
const url = new URL(`${XTTS_API_URL}/tts_stream`);
|
const url = new URL(`${XTTS_API_URL}/tts_stream?${qs.toString()}`);
|
||||||
const options = {
|
const options = {
|
||||||
hostname: url.hostname,
|
hostname: url.hostname,
|
||||||
port: url.port,
|
port: url.port,
|
||||||
path: url.pathname,
|
path: `${url.pathname}?${url.searchParams.toString()}`,
|
||||||
method: "POST",
|
method: "GET",
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"Content-Length": Buffer.byteLength(body),
|
|
||||||
},
|
|
||||||
timeout: 60000,
|
timeout: 60000,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -282,7 +277,6 @@ function streamXTTSAsPCM(text, language, speakerWav, onPcmChunk) {
|
|||||||
|
|
||||||
req.on("error", reject);
|
req.on("error", reject);
|
||||||
req.on("timeout", () => { req.destroy(); reject(new Error("XTTS API Timeout (60s)")); });
|
req.on("timeout", () => { req.destroy(); reject(new Error("XTTS API Timeout (60s)")); });
|
||||||
req.write(body);
|
|
||||||
req.end();
|
req.end();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user