Add more clear error messages to TTS

This commit is contained in:
Cohee
2023-06-05 16:57:58 +03:00
parent f8c5b17e57
commit 46bdee83bc
2 changed files with 3 additions and 3 deletions

View File

@ -127,14 +127,14 @@ class EdgeTtsProvider {
} }
) )
if (!response.ok) { if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${await response.json()}`) toastr.error(response.statusText);
throw new Error(`HTTP ${response.status}`)
} }
return response return response
} }
} }
function throwIfModuleMissing() { function throwIfModuleMissing() {
if (!modules.includes('edge-tts')) { if (!modules.includes('edge-tts')) {
toastr.error(`Edge TTS module not loaded. Add edge-tts to enable-modules and restart the Extras API.`) toastr.error(`Edge TTS module not loaded. Add edge-tts to enable-modules and restart the Extras API.`)
throw new Error(`Edge TTS module not loaded.`) throw new Error(`Edge TTS module not loaded.`)
} }

View File

@ -414,6 +414,7 @@ async function processTtsQueue() {
const voice = await ttsProvider.getVoice((voiceMap[char])) const voice = await ttsProvider.getVoice((voiceMap[char]))
const voiceId = voice.voice_id const voiceId = voice.voice_id
if (voiceId == null) { if (voiceId == null) {
toastr.error(`Specified voice for ${char} was not found. Check the TTS extension settings.`)
throw `Unable to attain voiceId for ${char}` throw `Unable to attain voiceId for ${char}`
} }
tts(text, voiceId) tts(text, voiceId)
@ -494,7 +495,6 @@ async function voicemapIsValid(parsedVoiceMap) {
async function updateVoiceMap() { async function updateVoiceMap() {
let isValidResult = false let isValidResult = false
const context = getContext()
const value = $('#tts_voice_map').val() const value = $('#tts_voice_map').val()
const parsedVoiceMap = parseVoiceMap(value) const parsedVoiceMap = parseVoiceMap(value)