Add Audio in Twine

In Twine, you can add audio via HTML tags, similar to how images work in Twine. This is the simplest option for adding audio like voice over on an individual passage. The W3 Schools documentation is a good resource for understanding the HTML code.

Audio with a player

If you want learners to have control over the audio, you can use the <audio controls> tag like the example below.

<audio controls>
  <source src="audio/voicemail.mp3" type="audio/mpeg">
Your browser does not support the audio element.

In this example, I published the file to a folder that also contains a folder for audio files.

This produces a simple audio player control. It may look a little different, depending on the browser, but this is a good way to let learners decide to listen to audio or not.

Autoplay audio

If you want the audio to autoplay on a passage, like the narration in more traditional elearning, use this code instead. However, don’t use autoplay audio on the first passage: many browsers won’t allow it.

<audio src="audio/voicemail.mp3" autoplay> </audio>

Harlowe Audio Library

If you want more complex audio controls, check out the Harlowe Audio Library, also called HAL.

These are the features of HAL, according to their website.

  • All the core features you’d expect from such a library: playing across passages, fading, looping, individual track volume levels, etc.
  • Support for audio playlists.
  • Support for “audio groups,” which let authors control track settings on groups of related tracks all at once.
  • Includes an optional, user-configurable sidebar with built-in audio controls; specifically a master volume control and a master mute button.
  • Supports preloading of audio, with an optional loading screen.
  • Configurable and extensible for users who need it, with sane defaults and a bevy of built-in features for users who don’t want to mess with any of that.

I haven’t personally needed this level of control for audio in Twine; usually this is used by game developers who want background music that persists across multiple passages. However, if you need something more advanced, HAL is available.