A modified build of Pink Trombone, the interactive vocal tract synthesizer.
Try it in your browser: Open the live demo
Pink Trombone is a speech synthesizer by Neil Thapen. A synthesizer is a program or instrument that makes sound from scratch rather than playing back a recording. Pink Trombone makes a voice by modelling the human vocal tract: the throat, mouth and nose. You drag the tongue and lips on screen, and the sound changes from "aah" to "eee" to "mmm" as you move.
This repo is a copy of zakaton/Pink-Trombone, a programmable version of Neil Thapen's original. It is a copy rather than a GitHub fork. Wobblefet changes the look to black and white, adds an XY pad (a square you drag a dot around in, where left-right and up-down each control one setting) for pitch and voice quality, and removes the microphone and MIDI keyboard inputs.
- How the shape of your mouth and throat turns one buzzing sound into different vowels and consonants (Music Technology, Physics, Linguistics).
- Source-filter synthesis: a sound source passed through a filter that shapes its tone. Here the source is the glottis (the vocal folds in your voicebox) and the filter is the vocal tract.
- What formants are: the resonant peaks that let you hear "ee" as different from "oo", even at the same pitch.
- How a web page makes sound in real time with the Web Audio API and an AudioWorklet (code that generates audio on its own thread so the sound does not stutter) (Computer Science).
- Open the live demo.
- Press start. Browsers block sound until you interact with the page, so this button switches audio on and then disappears.
- Turn your volume down a little first. The voice can be loud.
Controls:
| Control | What it does |
|---|---|
| start button | Switches the audio on. |
| disable wobble / enable wobble | Turns the natural pitch wobble (vibrato) off and on. |
| disable voice / enable voice | Turns the voice off and on. |
| Click or drag near the vowel markers in the mouth | Moves the tongue. The vowel changes as you drag. |
| Click and hold anywhere else in the tract | Closes the tract at that point to make a consonant. It opens again when you let go. |
| Drag the dot in the bottom pad left and right | Changes the pitch, from 80 Hz to 600 Hz. |
| Drag the dot in the bottom pad up and down | Changes tenseness: how breathy or pressed the voice sounds. |
On a touch screen you can use several fingers at once. Each finger makes its own constriction. There are no keyboard controls.
You will need:
- A web browser with Web Audio support (Chrome, Firefox, Safari or Edge).
- Python 3, to run a small local web server.
- Node.js, only if you want to change the code in
script/and rebuild.
The page has to be served over HTTP. Opening index.html straight from your file browser will not load the audio code.
-
Download the code. Either use Code > Download ZIP on GitHub, or run:
git clone https://github.com/godofecht/Wobblefet.git cd Wobblefet -
Start a local web server in the folder:
python3 -m http.server 8002
-
Open
http://localhost:8002in your browser and press start.
To change the code and see your changes, rebuild the two bundled files (pink-trombone.min.js and pink-trombone-worklet-processor.min.js) from the source in script/:
npm install
npm run devnpm run dev deletes the old bundles, rebuilds them with Rollup (a tool that joins many JavaScript files into one), and starts the same server on port 8002.
Your voice starts as a buzz from the glottis. On its own that buzz sounds the same whatever word you say. The vocal tract then filters it. Moving your tongue changes the width of the tube at each point along it, and that changes which frequencies ring out. Pink Trombone models the tract as a row of short tube sections, each with its own width. Sound waves travel along the row and partly bounce back wherever the width changes. This is a waveguide model, a way of simulating sound travelling down a tube.
| File or folder | What is in it |
|---|---|
index.html |
The page itself. It loads the bundled code and places the <pink-trombone> element. |
script/component.js |
Defines the <pink-trombone> custom HTML element and wires the UI to the audio. |
script/PinkTrombone.js |
Creates the audio nodes and connects them. |
script/audio/nodes/pinkTrombone/processors/Glottis.js |
The sound source: the buzz from the vocal folds. |
script/audio/nodes/pinkTrombone/processors/Tract.js |
The vocal tract filter: the tube sections and the waves between them. |
script/audio/nodes/pinkTrombone/processors/Nose.js |
The nasal cavity, used for sounds like "m" and "n". |
script/graphics/TractUI.js |
Draws the head and handles clicks and touches on it. |
script/graphics/GlottisUI.js |
The XY pad for pitch and tenseness. |
script/graphics/ButtonsUI.js |
The start, wobble and voice buttons. |
rollup.config.js |
Build settings that produce the two .min.js files. |
script/lib/xypad.js |
The XY pad library used by GlottisUI.js. |
images/ |
The demo GIF and the app icons. |
tools/make_icons.py |
The Python program that draws the app icons. |
- Change the pitch range of the XY pad. In
script/graphics/GlottisUI.js, findthis._frequency_range = { min: 80, max: 600 }and try a deep voice (40 to 200) or a high one (300 to 1200). Rebuild withnpm run dev. - Change the button colours or labels in
script/graphics/ButtonsUI.js. - Make the page say a word.
index.htmlcontains asay()function and asayUKATON()sequence inside anif (false)block. Change it toif (true), reload, and press any key. - Use the phoneme table under "Technical details" to write your own
say()sequence for a short word, such as "mama" or "no". - Change the vibrato. In
script/audio/nodes/pinkTrombone/processors/ParameterDescriptors.js,vibratoFrequency(default 6, in wobbles per second) andvibratoGain(default 0.005) set the speed and depth of the pitch wobble. Try a slow, deep wobble like an opera singer. - Ambitious: build one of the upstream wishlist ideas listed under "Technical details", starting from the
say()code inindex.html.
The original README below came from zakaton/Pink-Trombone. It still describes the programming interface of this build.
-
Save a local copy of
pink-trombone.min.jsandpink-trombone-worklet-processor.min.jsand keep them in the same folder. The first imports the second as an Audio Worklet Processor. -
In your HTML
<head>element, add the file as a module:<script src="pink-trombone.min.js" type="module"></script>
-
In your HTML
<body>element, add the custom element:<pink-trombone></pink-trombone>
-
In your JavaScript, get the element:
var pinkTromboneElement = document.querySelector("pink-trombone");
-
Add a
loadevent listener to it:pinkTromboneElement.addEventListener("load", myCallback);
-
In the
loadcallback, assign an Audio Context with.setAudioContext(myAudioContext). If you pass none, one is created for you. The method returns a Promise that resolves once the AudioWorkletProcessor module has loaded.function myCallback(event) { pinkTromboneElement.setAudioContext(myAudioContext) }
-
When the promise resolves, a Pink Trombone audio node exists. Connect it to other audio nodes from the element:
function myCallback(event) { pinkTromboneElement.setAudioContext(myAudioContext) .then(() => { const audioContext = pinkTromboneElement.audioContext pinkTromboneElement.connect(audioContext.destination); }); }
pinkTromboneElement.start(); // start generating sound
pinkTromboneElement.stop(); // stop generating soundpinkTromboneElement.enableUI(); // show the interactive visualization
pinkTromboneElement.startUI(); // start animating it
pinkTromboneElement.stopUI(); // stop animating it
pinkTromboneElement.disableUI(); // hide itThese audio parameters of the Pink Trombone audio node are available on the element:
pinkTromboneElement.intensity;
pinkTromboneElement.frequency;
pinkTromboneElement.tenseness;
pinkTromboneElement.loudness;
pinkTromboneElement.vibrato.frequency;
pinkTromboneElement.vibrato.gain;
pinkTromboneElement.vibrato.wobble;
// 'index' and 'diameter' are the tongue's position in the mouth
pinkTromboneElement.tongue.index;
pinkTromboneElement.tongue.diameter;To move between voiced and voiceless sound, set .tenseness and .loudness together, as the original version does:
function setVoiceness(voiceness) {
const tenseness = 1 - Math.cos((voiceness) * Math.PI * 0.5);
const loudness = Math.pow(tenseness, 0.25);
pinkTromboneElement.tenseness.value = tenseness;
pinkTromboneElement.loudness.value = loudness;
}
setVoiceness(1); // voiced
setVoiceness(0); // voicelessA constriction is an object with .index and .diameter audio parameters, connected to the Pink Trombone audio node.
// add one
var myConstriction = pinkTromboneElement.newConstriction(indexValue, diameterValue);
// change it
myConstriction.index.value = newIndexValue;
myConstriction.diameter.value = newDiameterValue;
// remove it
pinkTromboneElement.removeConstriction(myConstriction);Index and diameter values for some phonemes.
Tongue positions for vowels:
| Phoneme | As in | Index | Diameter |
|---|---|---|---|
| æ | pat | 14.93 | 2.78 |
| ɑ | part | 2.3 | 12.75 |
| ɒ | pot | 12 | 2.05 |
| ɔ | port (rounded) | 17.7 | 2.05 |
| ɪ | pit | 26.11 | 2.87 |
| i | peat | 27.2 | 2.2 |
| e | pet | 19.4 | 3.43 |
| ʌ | put | 17.8 | 2.46 |
| u | poot (rounded) | 22.8 | 2.05 |
| ə | pert | 20.7 | 2.8 |
Constriction values for consonants. Voiced and voiceless pairs share the same values and differ only in voiceness.
| Type | Phonemes | As in | Index | Diameter |
|---|---|---|---|---|
| Fricative | ʒ, ʃ | "s" in pleasure | 31 | 0.6 |
| Fricative | z, s | "z" in zoo | 36 | 0.6 |
| Fricative | v, f | "v" in very | 41 | 0.5 |
| Stop | g, k | "g" in go | 20 | 0 |
| Stop | d, t | "d" in den | 36 | 0 |
| Stop | b, p | "b" in bad | 41 | 0 |
| Nasal | ŋ | "ng" in hang | 20 | -1 |
| Nasal | n | "n" in not | 36 | -1 |
| Nasal | m | "m" in woman | 41 | -1 |
These clips, from the upstream README, show projects built on zakaton's version. Each one links to its original post.
zakaton listed these as ideas for others to build:
- IPA Speak n' See: take speech from the user with the MediaStream Recording API and approximate their articulation with Pink Trombone, so speakers can see how they speak.
- Phonetic Voice Editor: a cross between a text editor and a digital audio workstation, where you type phonemes instead of letters and use automation to shape cadence and pitch over time.
- SSML Simulator: a Speech Synthesis Markup Language emulator that takes an utterance and speaks it with Pink Trombone.
- Julius O. Smith III, "Physical audio signal processing for virtual musical instruments and audio effects."
- Story, Brad H. "A parametric model of the vocal tract area function for vowel and consonant simulation." The Journal of the Acoustical Society of America 117.5 (2005): 3231-3254.
- Lu, Hui-Ling, and J. O. Smith. "Glottal source modeling for singing voice synthesis." Proceedings of the 2000 International Computer Music Conference. 2000.
- Mullen, Jack. Physical modelling of the vocal tract with the 2D digital waveguide mesh. PhD thesis, University of York, 2006.
The live demo loads and plays.
xypadjs is a git submodule pointing at BcRikko/xypadjs. The page does not need it: it uses the built copy in script/lib/xypad.js. Run git submodule update --init only if you want the library's source.
You can use, copy, change and share this code, as long as anything you share that is built from it is also released under GPL-3.0 with its source code. See LICENSE (GNU General Public License v3.0).
Neil Thapen released the original Pink Trombone (version 1.1, March 2017) under the MIT licence. zakaton's programmable version, which this repo copies, is released under GPL-3.0.
- Pink Trombone by Neil Thapen, the original speech synthesizer.
- zakaton/Pink-Trombone, the programmable web-component version this repo is copied from, including the API documentation, phoneme table and project clips above.
- xypadjs by B.C.Rikko (MIT licence), the XY pad library in
script/lib/xypad.js. - Rollup, used to bundle the code.
- Changes in this repo, and the app icons, by Abhishek Shivakumar.






