diff --git a/index.html b/index.html index 39cd067..e70752c 100644 --- a/index.html +++ b/index.html @@ -676,7 +676,11 @@ async function tryVoicevox(text) { headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${apiKey}` }, body: JSON.stringify({ text: preprocessText(text), speaker: ttsSpeaker }), }); - if (!res.ok) return false; + if (!res.ok) { + const msg = res.status === 401 ? 'APIキーが無効です' : res.status === 503 ? 'VOICEVOXが起動していません' : `サーバーエラー (${res.status})`; + if (currentIdx === 0 && typeof showToast === 'function') showToast('VOICEVOX: ' + msg); + return false; + } const buf = await ctx.decodeAudioData(await res.arrayBuffer()); if (!isPlaying) return true; @@ -713,7 +717,9 @@ async function speak(text) { stopAudio(); let vvOk = false; - try { vvOk = (await tryVoicevox(text)) === true; } catch(e) {} + try { vvOk = (await tryVoicevox(text)) === true; } catch(e) { + if (currentIdx === 0 && typeof showToast === 'function') showToast('VOICEVOX エラー: ' + (e.message || e)); + } if (!isPlaying) return; if (vvOk) {