FORMANT-1 (v3.0) — Bio-inspired Speech Synthesis One-Liner
Kirill 7020d767 07.01.26 Wed 19:02:33
№
11889
0:03, track.webm (50.29KB)
%3Cvideo%20width%3D%22500%22style%3D%22position%3A%20static%3B%20pointer-events%3A%20inherit%3B%20display%3A%20inline%3B%20height%3A%20auto%3B%20max-width%3A%20100%25%3B%20max-height%3A%20100%25%3B%22%20controls%20autoplay%20loop%3E%3Csource%20src%3D%22%2Fbtb%2Fsrc%2F1767805353926-0.webm%22%3E%3C%2Fsource%3E%3C%2Fvideo%3E
Hi everyone!
I’m excited to share FORMANT-1, a lightweight speech synthesis engine built for the Bytebeat environment. This isn’t just a simple wave generator — it’s a mathematical model that simulates the biological mechanics of the human vocal tract.
In this demo, the engine says "HELLO".
Key Features:
LF-Source: Uses an asymmetric glottal impulse model for a natural "chesty" male timbre.
Nasal Cavity: Features an independent resonance channel (~280Hz) to add warmth and realism.
Dynamic Coarticulation: Real-time smoothing of formants for fluid speech transitions.
🚀 How to run it:
Open any online Bytebeat player (e.g., Dollchan Bytebeat or GreasyFork Bytebeat).
Set the Mode to JavaScript (or float).
Set the Sample Rate to 44100 (this is crucial for the filters to sound correct).
Paste the code below into the editor and hit Play.
💻 The Code:
t === 0 ? (window.m = {h:new Float32Array(16).fill(0),f1:500,f2:1500,p:100,a:0,n:0.1}) : 0,
sc = [[500,1500,0,0,0.8,0],[500,1800,100,1,0.1,0.1],[400,1000,102,0.8,0,0.3],[450,850,95,1,0,0.1],[0,0,0,0,0,0],[0,0,0,0,0,0]][Math.floor((t/44100*1.4)%6)]||[0,0,0,0,0,0],
window.m.f1 += (sc[0]-window.m.f1)*0.25,
window.m.f2 += (sc[1]-window.m.f2)*0.25,
window.m.p += (sc[2]-window.m.p)*0.12,
window.m.n += (sc[5]-window.m.n)*0.15,
ph = (t/44100*window.m.p)%1,
gl = window.m.p>0 ? (ph<0.6 ? Math.sin(3.14ph/0.6) : -Math.sin(3.14 (ph-0.6)/0.4)*0.25) : 0,
src = (gl+(Math.random()-0.5)0.06) sc[3] + (Math.random()-0.5)*sc[4],
window.m.a += ((sc[2]>0||sc[4]>0.5?1:0)-window.m.a)*0.3,
r1 = 0.996, c1 = 2r1 Math.cos(6.28*window.m.f1/44100),
o1 = src + c1window.m.h[0] - r1 r1*window.m.h[1],
window.m.h[1] = window.m.h[0], window.m.h[0] = o1,
v1 = o1(1-r1 r1),
r2 = 0.994, c2 = 2r2 Math.cos(6.28*window.m.f2/44100),
o2 = v1 + c2window.m.h[2] - r2 r2*window.m.h[3],
window.m.h[3] = window.m.h[2], window.m.h[2] = o2,
v2 = o2(1-r2 r2),
r3 = 0.994, c3 = 2r3 Math.cos(6.28*280/44100),
o3 = src + c3window.m.h[4] - r3 r3*window.m.h[5],
window.m.h[5] = window.m.h[4], window.m.h[4] = o3,
v3 = o3(1-r3 r3),
Math.tanh(((v20.8) + (v3 window.m.n2.0)) 12) * window.m.a
📚 Vowel Reference Map (Create your own words!)
Modify the sc array in the code using these F1/F2 frequency values:
Vowel F1 (Hz) F2 (Hz) Mouth Position
[A] (Father) 750 1200 Open
[E] (Bed) 500 1800 Mid-Front
[I] (See) 300 2300 High-Front
[O] (Hot) 500 900 Mid-Back
[U] (Boot) 350 800 High-Back
Tips:
To change Pitch, modify the 3rd value in the sc sub-arrays.
To make it Whisper, set the 4th value to 0 and increase the 5th value (Noise).
Enjoy the synthesis! Let me know if you find any cool new sounds.