Disclose browser speech processing before microphone use
Build and publish frontend / publish (push) Successful in 43s
Build and publish frontend / publish (push) Successful in 43s
This commit is contained in:
+16
@@ -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(); });
|
||||
|
||||
Reference in New Issue
Block a user