Add browser-local Piper WebAssembly speech
Build and publish frontend / publish (push) Failing after 6s

This commit is contained in:
Ein Anderssono
2026-10-16 06:47:59 +02:00
parent 474fd80a95
commit aed6b15a20
14 changed files with 332 additions and 22 deletions
+8 -11
View File
@@ -72,6 +72,7 @@
</section>
</main>
<footer id="version-footer">Frontend <span id="frontend-version">__FRONTEND_VERSION__</span> · API <span id="api-version">hämtar version…</span></footer>
<script src="/piper-runtime.js?v=__FRONTEND_VERSION__"></script>
<script src="/voice.js?v=__FRONTEND_VERSION__"></script>
<script>
const auth = document.querySelector('#auth');
@@ -251,17 +252,13 @@
const voiceLabel = document.createElement('label'); voiceLabel.textContent = 'Svensk röst';
const voice = document.createElement('select'); voice.setAttribute('aria-label', 'Svensk röst');
const defaultVoice = document.createElement('option'); defaultVoice.value = ''; defaultVoice.textContent = 'Systemets standardröst'; voice.append(defaultVoice);
function refreshVoices() {
const selected = voiceSettings.voiceName;
voice.replaceChildren(defaultVoice.cloneNode(true));
voiceController.getVoices().filter(entry => /^sv(-|$)/i.test(entry.lang)).forEach(entry => {
const option = document.createElement('option'); option.value = entry.name; option.textContent = `${entry.name} (${entry.lang})`; voice.append(option);
});
voice.value = selected;
}
refreshVoices();
window.speechSynthesis?.addEventListener?.('voiceschanged', refreshVoices);
voice.value = voiceSettings.voiceName; voiceLabel.append(voice); fieldset.append(voiceLabel);
const piperVoice = document.createElement('option');
piperVoice.value = 'piper-sv-nst';
piperVoice.textContent = 'Piper – svensk röst på enheten';
voice.append(piperVoice);
voice.value = piperVoice.value;
voiceSettings.voiceName = piperVoice.value;
voiceLabel.append(voice); fieldset.append(voiceLabel);
const signalLabel = document.createElement('label'); const signals = document.createElement('input');
signals.type = 'checkbox'; signals.checked = voiceSettings.soundSignals;
signalLabel.append(signals, document.createTextNode(' Ljudsignal vid röstinmatning')); fieldset.append(signalLabel);