mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
add missing session handling to silerotts
This commit is contained in:
@ -32,6 +32,7 @@ class SileroTtsProvider {
|
|||||||
// Used when provider settings are updated from UI
|
// Used when provider settings are updated from UI
|
||||||
this.settings.provider_endpoint = $('#silero_tts_endpoint').val()
|
this.settings.provider_endpoint = $('#silero_tts_endpoint').val()
|
||||||
saveTtsProviderSettings()
|
saveTtsProviderSettings()
|
||||||
|
this.refreshSession()
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadSettings(settings) {
|
async loadSettings(settings) {
|
||||||
@ -64,6 +65,7 @@ class SileroTtsProvider {
|
|||||||
|
|
||||||
$('#silero_tts_endpoint').val(this.settings.provider_endpoint)
|
$('#silero_tts_endpoint').val(this.settings.provider_endpoint)
|
||||||
$('#silero_tts_endpoint').on("input", () => {this.onSettingsChange()})
|
$('#silero_tts_endpoint').on("input", () => {this.onSettingsChange()})
|
||||||
|
this.refreshSession()
|
||||||
|
|
||||||
await this.checkReady()
|
await this.checkReady()
|
||||||
|
|
||||||
@ -78,6 +80,10 @@ class SileroTtsProvider {
|
|||||||
async onRefreshClick() {
|
async onRefreshClick() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async refreshSession() {
|
||||||
|
await this.initSession()
|
||||||
|
}
|
||||||
|
|
||||||
//#################//
|
//#################//
|
||||||
// TTS Interfaces //
|
// TTS Interfaces //
|
||||||
@ -125,7 +131,8 @@ class SileroTtsProvider {
|
|||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
"text": inputText,
|
"text": inputText,
|
||||||
"speaker": voiceId
|
"speaker": voiceId,
|
||||||
|
"session": "sillytavern"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -135,6 +142,29 @@ class SileroTtsProvider {
|
|||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async initSession() {
|
||||||
|
console.info(`requesting new session`)
|
||||||
|
const response = await doExtrasFetch(
|
||||||
|
`${this.settings.provider_endpoint}/init_session`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Cache-Control': 'no-cache' // Added this line to disable caching of file so new files are always played - Rolyat 7/7/23
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
"path": "sillytavern"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!response.ok && response.status !== 404) {
|
||||||
|
toastr.error(response.statusText, 'Fetching Session Failed');
|
||||||
|
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
|
||||||
|
}
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
// Interface not used by Silero TTS
|
// Interface not used by Silero TTS
|
||||||
async fetchTtsFromHistory(history_item_id) {
|
async fetchTtsFromHistory(history_item_id) {
|
||||||
|
Reference in New Issue
Block a user