Compare commits

...
2 Commits
Author SHA1 Message Date
Gitea Actions c9e31d23ba Release 0.1.27 [auto-version-bump] 2026-10-15 09:57:23 +02:00
Ein Anderssono 1f9fc464d4 Disclose browser speech processing before microphone use
Build and publish frontend / publish (push) Successful in 43s
2026-10-15 09:56:46 +02:00
6 changed files with 24 additions and 5 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ The separate `/admin` route provides an authenticated, read-only operations view
The game is text- and dialogue-based and uses no images. Place descriptions include sound, smell, air/temperature, touch/surface, and spatial-orientation cues. Visible details may also be described in words, but are never required to understand the scene or play. The transcript is screen-reader announced, and Enter submits the input while Shift+Enter inserts a newline; no separate send button is required.
Voice input and output are optional browser features. The microphone button beside the text field uses Web Speech API when available and sends only its final Swedish transcript through the same submission path as typed text. Writing `röstinställningar` or saying `röstkommando alternativ` opens the temporary controls in the dialogue. The player can choose `Spelets röst`, `Skärmläsare`, or `Endast text`, select available Swedish speech voices and rate, and enable auto-read and short audio cues. The default mode is `Skärmläsare`; auto-read is off. These preferences are stored in browser `localStorage`. If speech APIs are unavailable or permission is denied, text play remains available. No audio is uploaded or stored by this feature.
Voice input and output are optional browser features. The microphone button beside the text field uses Web Speech API when available and sends only its final Swedish transcript through the same submission path as typed text. Before its first use, the client explains that the browser may process audio through a provider-selected service; the game itself does not receive or store recordings, while the final transcript is saved as ordinary dialogue. Writing `röstinställningar` or saying `röstkommando alternativ` opens the temporary controls in the dialogue. The player can choose `Spelets röst`, `Skärmläsare`, or `Endast text`, select available Swedish speech voices and rate, and enable auto-read and short audio cues. The default mode is `Skärmläsare`; auto-read is off. These preferences are stored in browser `localStorage`. If speech APIs are unavailable or permission is denied, text play remains available.
System voice commands require the prefix `röstkommando`: `upprepa`, `avbryt`, `hjälp`, `alternativ`, or `paus`. Without the prefix, the same words remain ordinary dialogue. Speech recognition and synthesis are browser-dependent; release acceptance must record which real iPhone/Safari/VoiceOver and Android/Chrome/TalkBack combinations were actually checked.
+1 -1
View File
@@ -1 +1 @@
0.1.26
0.1.27
+2 -2
View File
@@ -2,5 +2,5 @@ apiVersion: v2
name: ai-spel-frontend
description: Static web frontend for the Swedish life simulator
type: application
version: 0.1.26
appVersion: "0.1.26"
version: 0.1.27
appVersion: "0.1.27"
+16
View File
@@ -88,6 +88,7 @@
let voiceSettings = window.GameVoice.loadSettings(localStorage, voiceSettingsKey);
let voiceController;
let audioContext;
let voiceDisclosureAcknowledged = false;
let adminOffset = 0;
const adminPageSize = 50;
@@ -211,6 +212,20 @@
addVoiceButton(item, 'Stäng röstinställningar', () => item.remove());
transcript.append(item); item.scrollIntoView({block: 'end'}); mode.focus();
}
function requestVoiceDisclosure() {
const item = document.createElement('li'); item.dataset.role = 'voice-controls';
item.setAttribute('aria-label', 'Information om mikrofonen');
const message = document.createElement('p');
message.textContent = 'Innan du startar: webbläsarens taligenkänning kan behandla ljud genom en tjänst som webbläsaren väljer. Spelet tar inte emot eller sparar ljudinspelningen. Den färdiga transkriberingen skickas och sparas som din vanliga dialog. Fortsätt bara om du godkänner webbläsarens hantering av tal.';
item.append(message);
addVoiceButton(item, 'Jag förstår – starta mikrofonen', () => {
voiceDisclosureAcknowledged = true;
item.remove();
voiceController.startListening();
});
transcript.append(item); item.scrollIntoView({block: 'end'});
item.querySelector('button').focus();
}
function handleVoiceCommand(message, source) {
const parsed = window.GameVoice.parseVoiceCommand(message, {requirePrefix: source === 'voice'});
if (!parsed) return false;
@@ -226,6 +241,7 @@
}
document.querySelector('#microphone').addEventListener('click', () => {
if (voiceController.getState() === 'LISTENING') voiceController.stopListening();
else if (!voiceDisclosureAcknowledged && voiceController.supportsRecognition()) requestVoiceDisclosure();
else voiceController.startListening();
});
document.addEventListener('visibilitychange', () => { if (document.hidden) voiceController.stopAll(); });
+2
View File
@@ -11,6 +11,8 @@ grep -q 'id="message" name="message"' index.html
grep -q 'id="microphone" aria-pressed="false"' index.html
grep -q 'id="voice-status" role="status" aria-live="polite"' index.html
grep -q "window.GameVoice.createVoiceController" index.html
grep -q 'Jag förstår – starta mikrofonen' index.html
grep -q 'supportsRecognition' voice.js
grep -q 'COPY voice.js /usr/share/nginx/html/voice.js' Dockerfile
grep -q "SpeechRecognition || win.webkitSpeechRecognition" voice.js
grep -q "submitMessage(text, 'voice')" index.html
+2 -1
View File
@@ -201,7 +201,8 @@
function getState() { return state; }
function getSettings() { return {...settings}; }
function getVoices() { return availableVoices(); }
return {startListening, stopListening, speak, cancelSpeech, stopAll, update, getState, getSettings, getVoices};
function supportsRecognition() { return Boolean(win.SpeechRecognition || win.webkitSpeechRecognition); }
return {startListening, stopListening, speak, cancelSpeech, stopAll, update, getState, getSettings, getVoices, supportsRecognition};
}
root.GameVoice = {createVoiceController, DEFAULT_SETTINGS, parseVoiceCommand, loadSettings, saveSettings};