Skip to content
godofechtPublic

About

A modified build of Pink Trombone, the interactive vocal tract synthesizer.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

Wobblefet

A modified build of Pink Trombone, the interactive vocal tract synthesizer.

Try it in your browser: Open the live demo

The original pink Pink Trombone interface. A side view of a head shows the nasal cavity at the top and the oral cavity below it, with phoneme letters marked along the tract. Start, disable wobble and disable voice buttons sit on the right, and a long horizontal bar for pitch runs along the bottom.

What this is

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.

What you can learn from it

  • 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).

Run it

In your browser

  1. Open the live demo.
  2. Press start. Browsers block sound until you interact with the page, so this button switches audio on and then disappears.
  3. 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.

On your own computer

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.

  1. Download the code. Either use Code > Download ZIP on GitHub, or run:

    git clone https://github.com/godofecht/Wobblefet.git
    cd Wobblefet
  2. Start a local web server in the folder:

    python3 -m http.server 8002
  3. Open http://localhost:8002 in 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 dev

npm 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.

How it works

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.

Ideas to try

  1. Change the pitch range of the XY pad. In script/graphics/GlottisUI.js, find this._frequency_range = { min: 80, max: 600 } and try a deep voice (40 to 200) or a high one (300 to 1200). Rebuild with npm run dev.
  2. Change the button colours or labels in script/graphics/ButtonsUI.js.
  3. Make the page say a word. index.html contains a say() function and a sayUKATON() sequence inside an if (false) block. Change it to if (true), reload, and press any key.
  4. Use the phoneme table under "Technical details" to write your own say() sequence for a short word, such as "mama" or "no".
  5. Change the vibrato. In script/audio/nodes/pinkTrombone/processors/ParameterDescriptors.js, vibratoFrequency (default 6, in wobbles per second) and vibratoGain (default 0.005) set the speed and depth of the pitch wobble. Try a slow, deep wobble like an opera singer.
  6. Ambitious: build one of the upstream wishlist ideas listed under "Technical details", starting from the say() code in index.html.

Technical details

The original README below came from zakaton/Pink-Trombone. It still describes the programming interface of this build.

Setting up in your own page

  1. Save a local copy of pink-trombone.min.js and pink-trombone-worklet-processor.min.js and keep them in the same folder. The first imports the second as an Audio Worklet Processor.

  2. In your HTML <head> element, add the file as a module:

    <script src="pink-trombone.min.js" type="module"></script>
  3. In your HTML <body> element, add the custom element:

    <pink-trombone></pink-trombone>
  4. In your JavaScript, get the element:

    var pinkTromboneElement = document.querySelector("pink-trombone");
  5. Add a load event listener to it:

    pinkTromboneElement.addEventListener("load", myCallback);
  6. In the load callback, 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)
    }
  7. 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);
        });
    }

Producing sound

pinkTromboneElement.start(); // start generating sound
pinkTromboneElement.stop();  // stop generating sound

Enabling and disabling the UI

pinkTromboneElement.enableUI();  // show the interactive visualization
pinkTromboneElement.startUI();   // start animating it
pinkTromboneElement.stopUI();    // stop animating it
pinkTromboneElement.disableUI(); // hide it

Audio parameters

These 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); // voiceless

Vocal tract constrictions

A 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);

Common phonemes

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

Projects built on Pink Trombone

These clips, from the upstream README, show projects built on zakaton's version. Each one links to its original post.

Pink Trombone in a browser with a long row of phoneme and parameter buttons above it, and below it a laptop next to a small MIDI keyboard with drum pads, played by two hands.

A browser page titled "Completed training" with a training performance graph whose loss curve falls over time, next to a code editor and a webcam view of the developer.

A Pink Trombone editor page with text fields for frequency, tenseness, tongue and constriction values and a timeline, beside the vocal tract and a webcam view of the developer.

A page with a grid of phoneme buttons such as pAt, pEt and Zoo above Pink Trombone, and below it the words "hello world" typed as scattered letters.

Pink Trombone on the left of the screen, a code editor on the right, and a webcam view of the developer moving his hand to control the voice.

The pink Pink Trombone vocal tract with its start, disable wobble and enable voice buttons, with the tongue and lips moving as it speaks.

Upstream wishlist

zakaton listed these as ideas for others to build:

Bibliography

Project status

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.

Licence

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.

Credits

  • 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.

About

A modified build of Pink Trombone, the interactive vocal tract synthesizer.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages