mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
TTS plugin adjustments
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
import { callPopup, saveSettingsDebounced } from '../../../script.js'
|
import { callPopup, is_send_press, saveSettingsDebounced } from '../../../script.js'
|
||||||
import { extension_settings, getContext } from '../../extensions.js'
|
import { extension_settings, getContext } from '../../extensions.js'
|
||||||
|
import { is_group_generating } from '../../group-chats.js'
|
||||||
import { getStringHash } from '../../utils.js'
|
import { getStringHash } from '../../utils.js'
|
||||||
import { ElevenLabsTtsProvider } from './elevenlabs.js'
|
import { ElevenLabsTtsProvider } from './elevenlabs.js'
|
||||||
import { SileroTtsProvider } from './silerotts.js'
|
import { SileroTtsProvider } from './silerotts.js'
|
||||||
@ -43,6 +44,11 @@ async function moduleWorker() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Message is currently being generated
|
||||||
|
if (is_send_press || is_group_generating) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Chat/character/group changed
|
// Chat/character/group changed
|
||||||
if (
|
if (
|
||||||
(context.groupId && lastGroupId !== context.groupId) ||
|
(context.groupId && lastGroupId !== context.groupId) ||
|
||||||
@ -115,7 +121,7 @@ async function playAudioData(audioBlob) {
|
|||||||
window['tts_preview'] = function (id) {
|
window['tts_preview'] = function (id) {
|
||||||
const audio = document.getElementById(id)
|
const audio = document.getElementById(id)
|
||||||
|
|
||||||
if (!audio.hidden) {
|
if (!$(audio).data('disabled')) {
|
||||||
audio.play()
|
audio.play()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -131,7 +137,7 @@ async function onTtsVoicesClick() {
|
|||||||
|
|
||||||
for (const voice of voiceIds) {
|
for (const voice of voiceIds) {
|
||||||
popupText += `<div class="voice_preview"><span class="voice_lang">${voice.lang || ''}</span> <b class="voice_name">${voice.name}</b> <i onclick="tts_preview('${voice.voice_id}')" class="fa-solid fa-play"></i></div>`
|
popupText += `<div class="voice_preview"><span class="voice_lang">${voice.lang || ''}</span> <b class="voice_name">${voice.name}</b> <i onclick="tts_preview('${voice.voice_id}')" class="fa-solid fa-play"></i></div>`
|
||||||
popupText += `<audio id="${voice.voice_id}" src="${voice.preview_url}" hidden="${!!voice.preview_url}"></audio>`
|
popupText += `<audio id="${voice.voice_id}" src="${voice.preview_url}" data-disabled="${voice.preview_url == false}"></audio>`
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
popupText = 'Could not load voices list. Check your API key.'
|
popupText = 'Could not load voices list. Check your API key.'
|
||||||
|
@ -87,7 +87,7 @@ class SystemTtsProvider {
|
|||||||
return speechSynthesis
|
return speechSynthesis
|
||||||
.getVoices()
|
.getVoices()
|
||||||
.sort((a, b) => a.lang.localeCompare(b.lang) || a.name.localeCompare(b.name))
|
.sort((a, b) => a.lang.localeCompare(b.lang) || a.name.localeCompare(b.name))
|
||||||
.map(x => ({ name: x.name, voice_id: x.voiceURI, preview_url: '', lang: x.lang }));
|
.map(x => ({ name: x.name, voice_id: x.voiceURI, preview_url: false, lang: x.lang }));
|
||||||
}
|
}
|
||||||
|
|
||||||
previewTtsVoice(voiceId) {
|
previewTtsVoice(voiceId) {
|
||||||
|
Reference in New Issue
Block a user