mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Properly check for system TTS support
This commit is contained in:
@ -4080,7 +4080,7 @@ function isHordeGenerationNotAllowed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function cancelTtsPlay() {
|
export function cancelTtsPlay() {
|
||||||
if (speechSynthesis) {
|
if ('speechSynthesis' in window) {
|
||||||
speechSynthesis.cancel();
|
speechSynthesis.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class SystemTtsProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get settingsHtml() {
|
get settingsHtml() {
|
||||||
if (!window.speechSynthesis) {
|
if (!('speechSynthesis' in window)) {
|
||||||
return "Your browser or operating system doesn't support speech synthesis";
|
return "Your browser or operating system doesn't support speech synthesis";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ class SystemTtsProvider {
|
|||||||
// TTS Interfaces //
|
// TTS Interfaces //
|
||||||
//#################//
|
//#################//
|
||||||
fetchTtsVoiceIds() {
|
fetchTtsVoiceIds() {
|
||||||
if (!window.speechSynthesis) {
|
if (!('speechSynthesis' in window)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +91,10 @@ class SystemTtsProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
previewTtsVoice(voiceId) {
|
previewTtsVoice(voiceId) {
|
||||||
|
if (!('speechSynthesis' in window)) {
|
||||||
|
throw 'Speech synthesis API is not supported';
|
||||||
|
}
|
||||||
|
|
||||||
const voice = speechSynthesis.getVoices().find(x => x.voiceURI === voiceId);
|
const voice = speechSynthesis.getVoices().find(x => x.voiceURI === voiceId);
|
||||||
|
|
||||||
if (!voice) {
|
if (!voice) {
|
||||||
@ -107,11 +111,11 @@ class SystemTtsProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getVoice(voiceName) {
|
async getVoice(voiceName) {
|
||||||
if (!window.speechSynthesis) {
|
if (!('speechSynthesis' in window)) {
|
||||||
return { voice_id: null }
|
return { voice_id: null }
|
||||||
}
|
}
|
||||||
|
|
||||||
const voices = window.speechSynthesis.getVoices();
|
const voices = speechSynthesis.getVoices();
|
||||||
const match = voices.find(x => x.name == voiceName);
|
const match = voices.find(x => x.name == voiceName);
|
||||||
|
|
||||||
if (!match) {
|
if (!match) {
|
||||||
@ -122,7 +126,7 @@ class SystemTtsProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async generateTts(text, voiceId) {
|
async generateTts(text, voiceId) {
|
||||||
if (!window.speechSynthesis) {
|
if (!('speechSynthesis' in window)) {
|
||||||
throw 'Speech synthesis API is not supported';
|
throw 'Speech synthesis API is not supported';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user