Voci: anche le risposte del motore e le scelte dei dialoghi hanno la voce; make ascolta le riascolta con Whisper; rifatte quelle storpiate

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ApqNBvNbNCwXqR2RLo8QJh
This commit is contained in:
2026-10-24 20:49:52 +02:00
co-authored by Claude Opus 5.5
parent bde9a790e5
commit 96b3779ad1
65 changed files with 232 additions and 34 deletions
+5 -2
View File
@@ -15,6 +15,9 @@ const DEFAULT_LINES = {
drop: 'Non è roba mia da buttare.',
with: 'Non funziona.',
};
const HAVE_IT = 'Ce l\'ho già.', DROPPED = 'Questo non mi serve: via.', KEEP_IT = 'Meglio tenerlo: potrebbe servirmi.';
// Le battute che il motore dice da sé (quando la storia non ne ha una): anche loro hanno la voce (make voci).
export const ENGINE_LINES = [...Object.values(DEFAULT_LINES).filter(Boolean), HAVE_IT, DROPPED, KEEP_IT];
const SPEED = 95;
// Solo profilo, come i cicli di camminata: 'up' e 'down' lasciano il verso com'è.
const FACING = { left: -1, right: 1 };
@@ -181,9 +184,9 @@ export class Game {
}
if (def.actions?.[verb]) return def.actions[verb];
if (verb === 'walk') return h?.exit ? [{ go: h.exit.scene, at: h.exit.at, face: h.exit.face }] : [];
if (verb === 'take' && !h) return [{ say: 'Ce l\'ho già.' }];
if (verb === 'take' && !h) return [{ say: HAVE_IT }];
// Si butta solo quello che non serve alla storia (`droppable`): gli oggetti indispensabili restano.
if (verb === 'drop' && !h) return def.droppable ? [{ say: 'Questo non mi serve: via.' }, { drop: target }] : [{ say: 'Meglio tenerlo: potrebbe servirmi.' }];
if (verb === 'drop' && !h) return def.droppable ? [{ say: DROPPED }, { drop: target }] : [{ say: KEEP_IT }];
return DEFAULT_LINES[verb] ? [{ say: DEFAULT_LINES[verb] }] : [];
}
+5
View File
@@ -1,6 +1,8 @@
// Voci dei personaggi: un mp3 per battuta (generati da tools/voci.mjs), cercati per chi parla e testo.
// Senza assets/voices/index.json, o per una battuta nuova non ancora generata, il gioco resta muto e va avanti.
import { ENGINE_LINES } from './game.js';
export const voiceKey = (who, text) => `${who}|${text}`;
// Tutte le battute della storia, ovunque stiano (scene, oggetti, dialoghi, rami `if`), più le righe dell'introduzione
@@ -12,12 +14,15 @@ export function voiceLines(story) {
if (Array.isArray(value)) return value.forEach(visit);
if (!value || typeof value !== 'object') return;
if (typeof value.say === 'string') add(value.who ?? 'andrea', value.say);
// Le scelte dei dialoghi: Andrea ripete a voce l'opzione scelta (quando non ha una `say` sua).
if (Array.isArray(value.options)) for (const o of value.options) if (typeof o.text === 'string' && o.say == null) add('andrea', o.text);
Object.values(value).forEach(visit);
};
for (const line of story.intro ?? []) for (const text of typeof line === 'string' ? [line] : Object.values(line.rione)) add('andrea', text);
visit(story.scenes);
visit(story.items);
visit(story.dialogues);
for (const text of ENGINE_LINES) add('andrea', text);
return [...seen.values()];
}