Rework sound effects and add pre-generated Piper narration

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
denis
2026-10-16 12:29:51 +02:00
parent 61eccb2f80
commit 7050cb1ac6
60 changed files with 918 additions and 83 deletions
+20
View File
@@ -0,0 +1,20 @@
// Clé de narration : relie un texte de niveau à son fichier audio pré-généré.
// Doit rester strictement identique à scripts/voice_key.py (vecteurs de test communs).
const FNV_OFFSET = 0xcbf29ce484222325n;
const FNV_PRIME = 0x100000001b3n;
const MASK = 0xffffffffffffffffn;
/** Texte réellement lu : sans backticks Markdown, espaces normalisés. */
export function speechText(text) {
return text.replace(/`/g, '').replace(/\s+/g, ' ').trim();
}
/** Empreinte FNV-1a 64 bits (16 caractères hexadécimaux) de la langue et du texte lu. */
export function speechKey(lang, text) {
let value = FNV_OFFSET;
for (const byte of new TextEncoder().encode(`${lang}\n${speechText(text)}`)) {
value = ((value ^ BigInt(byte)) * FNV_PRIME) & MASK;
}
return value.toString(16).padStart(16, '0');
}