Chunkify NovelAI TTS

This commit is contained in:
Cohee
2024-01-01 21:31:08 +02:00
parent 58462d96d2
commit b315778e32
3 changed files with 43 additions and 24 deletions

View File

@@ -463,13 +463,25 @@ function saveLastValues() {
}
async function tts(text, voiceId, char) {
async function processResponse(response) {
// RVC injection
if (extension_settings.rvc.enabled && typeof window['rvcVoiceConversion'] === 'function')
response = await window['rvcVoiceConversion'](response, char, text);
await addAudioJob(response);
}
let response = await ttsProvider.generateTts(text, voiceId);
// RVC injection
if (extension_settings.rvc.enabled && typeof window['rvcVoiceConversion'] === 'function')
response = await window['rvcVoiceConversion'](response, char, text);
// If async generator, process every chunk as it comes in
if (typeof response[Symbol.asyncIterator] === 'function') {
for await (const chunk of response) {
await processResponse(chunk);
}
} else {
await processResponse(response);
}
addAudioJob(response);
completeTtsJob();
}