A small library for making text appear as if spoken.
It types text one character at a time, knows how to handle formatting tags -- and pauses at commas and other punctuation.
Skipping is also supported, for longer texts.
Use it for visual novels, twine games, anything you can think of!
Try the demo.
Add speak.js to your page. Then call speak with any DOM element as its first argument.
// Take any DOM element
const element = document.querySelector('.whateverElementYouWantToUse');
// Pass it to speak
speak(element);Calling skip will skip to the end of the current text.
// Skip to the end
skip();Using the data attribute data-speed:
<div class="dialog" data-speed=".3">This line will be spoken s l o w l y.</div>Setting the current speed in your function call:
// This will set the current speaking speed at 50%
speak(element, .5);