Enable automatic speech for game replies
Build and publish frontend / publish (push) Failing after 3s
Build and publish frontend / publish (push) Failing after 3s
This commit is contained in:
@@ -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. 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.
|
||||
Voice input and output are browser features. Every new game reply is read automatically with the browser's Swedish speech synthesis by default, including character creation and gameplay; the transcript remains available as text. 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 or disable auto-read and short audio cues. The default mode is `Spelets röst` with auto-read on. Screen-reader and text-only modes remain explicit alternatives. These preferences are stored in browser `localStorage`. If speech APIs are unavailable, text play remains available.
|
||||
|
||||
When a character or NPC is created, its saved voice identity is masculine, feminine, or neutral. The biography prompt only assigns masculine/feminine when the character is explicitly described that way; otherwise it uses neutral. Speech synthesis applies a stable, subtly varied pitch/rate profile per character, so a character keeps the same sound across visits. Narration always uses neutral pitch. The browser's selected Swedish voice still determines the underlying voice, so the exact sound depends on installed system voices.
|
||||
|
||||
|
||||
@@ -176,6 +176,9 @@ test('settings survive reload and invalid storage falls back to accessible defau
|
||||
vm.runInNewContext(source, {window: global, globalThis: global, Promise, String, Math, Object});
|
||||
const values = new Map();
|
||||
const storage = {getItem: key => values.get(key) || null, setItem: (key, value) => values.set(key, value)};
|
||||
const defaults = GameVoice.loadSettings(storage, 'new-player');
|
||||
assert.equal(defaults.mode, 'game-voice');
|
||||
assert.equal(defaults.autoSpeak, true);
|
||||
const requested = {...GameVoice.DEFAULT_SETTINGS, mode: 'game-voice', autoSpeak: true, rate: 1.5, voiceName: 'Svensk'};
|
||||
assert.equal(GameVoice.saveSettings(storage, 'voice', requested), true);
|
||||
const loaded = GameVoice.loadSettings(storage, 'voice');
|
||||
@@ -184,6 +187,7 @@ test('settings survive reload and invalid storage falls back to accessible defau
|
||||
assert.equal(loaded.rate, 1.5);
|
||||
assert.equal(loaded.voiceName, 'Svensk');
|
||||
values.set('voice', '{trasig');
|
||||
assert.equal(GameVoice.loadSettings(storage, 'voice').mode, 'screen-reader');
|
||||
assert.equal(GameVoice.loadSettings(storage, 'voice').mode, 'game-voice');
|
||||
assert.equal(GameVoice.loadSettings(storage, 'voice').autoSpeak, true);
|
||||
assert.equal(GameVoice.saveSettings({setItem() { throw new Error('blocked'); }}, 'voice', requested), false);
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* Browser voice adapters. Kept independent of the game submission and API layer. */
|
||||
(function exposeVoice(root) {
|
||||
const DEFAULT_SETTINGS = Object.freeze({
|
||||
mode: 'screen-reader',
|
||||
autoSpeak: false,
|
||||
mode: 'game-voice',
|
||||
autoSpeak: true,
|
||||
language: 'sv-SE',
|
||||
rate: 1,
|
||||
voiceName: '',
|
||||
|
||||
Reference in New Issue
Block a user