mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Make less obtrusive
This commit is contained in:
@ -44,8 +44,8 @@ class SileroTtsProvider {
|
|||||||
// Only accept keys defined in defaultSettings
|
// Only accept keys defined in defaultSettings
|
||||||
this.settings = this.defaultSettings
|
this.settings = this.defaultSettings
|
||||||
|
|
||||||
for (const key in settings){
|
for (const key in settings) {
|
||||||
if (key in this.settings){
|
if (key in this.settings) {
|
||||||
this.settings[key] = settings[key]
|
this.settings[key] = settings[key]
|
||||||
} else {
|
} else {
|
||||||
throw `Invalid setting passed to TTS Provider: ${key}`
|
throw `Invalid setting passed to TTS Provider: ${key}`
|
||||||
@ -64,7 +64,7 @@ class SileroTtsProvider {
|
|||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
$('#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()
|
this.refreshSession()
|
||||||
|
|
||||||
await this.checkReady()
|
await this.checkReady()
|
||||||
@ -73,14 +73,14 @@ class SileroTtsProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Perform a simple readiness check by trying to fetch voiceIds
|
// Perform a simple readiness check by trying to fetch voiceIds
|
||||||
async checkReady(){
|
async checkReady() {
|
||||||
await this.fetchTtsVoiceObjects()
|
await this.fetchTtsVoiceObjects()
|
||||||
}
|
}
|
||||||
|
|
||||||
async onRefreshClick() {
|
async onRefreshClick() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
async refreshSession() {
|
async refreshSession() {
|
||||||
await this.initSession()
|
await this.initSession()
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ class SileroTtsProvider {
|
|||||||
return match
|
return match
|
||||||
}
|
}
|
||||||
|
|
||||||
async generateTts(text, voiceId){
|
async generateTts(text, voiceId) {
|
||||||
const response = await this.fetchTtsGeneration(text, voiceId)
|
const response = await this.fetchTtsGeneration(text, voiceId)
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ class SileroTtsProvider {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'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
|
'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({
|
body: JSON.stringify({
|
||||||
"text": inputText,
|
"text": inputText,
|
||||||
@ -142,28 +142,30 @@ class SileroTtsProvider {
|
|||||||
}
|
}
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
async initSession() {
|
|
||||||
console.info(`requesting new session`)
|
|
||||||
const response = await doExtrasFetch(
|
|
||||||
`${this.settings.provider_endpoint}/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) {
|
async initSession() {
|
||||||
toastr.error(response.statusText, 'Fetching Session Failed');
|
console.info(`Silero TTS: requesting new session`);
|
||||||
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
|
try {
|
||||||
|
const response = await doExtrasFetch(
|
||||||
|
`${this.settings.provider_endpoint}/session`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Cache-Control': 'no-cache',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
"path": "sillytavern",
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!response.ok && response.status !== 404) {
|
||||||
|
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.info('Silero TTS: endpoint not available', error);
|
||||||
}
|
}
|
||||||
return response
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interface not used by Silero TTS
|
// Interface not used by Silero TTS
|
||||||
|
Reference in New Issue
Block a user