Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


                <div class="voiceinator">
  <h1>Text to Speech Robot</h1>

  <select name="voice" id="voices">
    <option value="">Select A Voice</option>

  <label for="rate">Rate:</label>
  <input name="rate" id="rate" type="range" min="0" max="16" value="2.7" step="0.1" list="tickmarks">
  <datalist id="tickmarks">
    <option value="0">
    <option value="1">
    <option value="2">
    <option value="3">
    <option value="4">
    <option value="5">
    <option value="6">
    <option value="7">
    <option value="8">
    <option value="9">
    <option value="10">
    <option value="11">
    <option value="12">
    <option value="13">
    <option value="14">
    <option value="15">
    <option value="16">

  <label for="pitch">Pitch:</label>
  <input name="pitch" type="range" min="0" max="2" step="0.1">
  <textarea name="text">Allow me to read your burdensome web articles to you.</textarea>
  <button id="stop">Stop</button>
  <button id="speak" class="">Speak</button>
  <button id="pause" class="hidden">Pause</button>
  <button id="resume" class="hidden">Resume</button>



                html { box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }

body {
  margin: 0;
  padding: 0;
  font-family: monospace;
  display: flex;
  min-height: 100vh;
  align-items: center;
  background-color: #ddd;

.voiceinator {
  padding: 0 1rem 1rem;
  width: 50rem;
  margin: auto;
  border-radius: 4px;
  background: white;
  overflow: hidden;
  z-index: 1;

h1 {
  width: 100%;
  padding: 0.5rem;
  background: LightSlateGrey;
  color: white;
  text-align: center;

.voiceinator input,
.voiceinator button,
.voiceinator select,
.voiceinator textarea {
  width: 100%;
  display: block;
  margin: 10px 0;
  padding: 10px;
  border: 0;
  font-size: 1rem;
  background: #eee;
  outline: 0;

textarea {
  height: 20rem;
  min-height: 50vh;

.voiceinator button {
  background: LightSlateGrey;
  color: white;
  width: 49%;
  float: right; /* it seems out of place now, but it is already in place, so */
  margin-bottom: 0;
  font-size: 1.5rem;
  cursor: pointer;

.voiceinator button:active { top: 2px; }
.voiceinator button:nth-of-type(1) { margin-left: 2%; }

.hidden { display: none !important; }


                // Forked from - added pause/resume, default faster. 

const msg = new SpeechSynthesisUtterance();
let voices = []; //empty array for voices
const voicesDropdown = document.querySelector('[name="voice"]');
const options = document.querySelectorAll('[type="range"], [name="text"]');
const rate = document.querySelector('#rate');
const speakButton = document.querySelector('#speak'); //start to speak
const stopButton = document.querySelector('#stop'); //stop
const pauseButton = document.querySelector('#pause'); //pause
const resumeButton = document.querySelector('#resume'); //resume
msg.text = document.querySelector('[name="text"]').value;

function populateVoices() {
  voices = this.getVoices();
  voicesDropdown.innerHTML = voices
  .filter(voice => voice.lang.includes('en')) // showing only english voices
  .map(voice => `<option value="${}">${} (${voice.lang})</option>`) //all of the voices 

function setVoice() {
  msg.voice = voices.find(voice => === this.value); //loop over every single voices in the array and find the one where it's name attribute is the same as the option that was currently selected

function toggle(startOver = true) {
  //restart speaking
  if (startOver) {

function pause() {

function resume() {

function setOption() {
  console.log(, this.value);
  msg[] = this.value;

msg.onend = function(event) {
  console.log('Utterance has finished ' + event.elapsedTime + ' milliseconds.');

msg.rate = 2.7; // default rate on load
speechSynthesis.addEventListener('voiceschanged', populateVoices);
voicesDropdown.addEventListener('change', setVoice);
options.forEach(option => option.addEventListener('change', setOption));
speakButton.addEventListener('click', toggle);
pauseButton.addEventListener('click', pause);
resumeButton.addEventListener('click', resume);
stopButton.addEventListener('click', () => toggle(false));