Pen Settings

HTML

CSS

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

JavaScript

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

Behavior

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

              
                <input class="text" type="text" placeholder="insert text" />

<select class="language">
  <option value="en-US">American English</option>
  <option value="en-GB">GB English</option>
  <option value="de-DE">German</option>
  <option value="it-IT">Italian</option>
</select>
<select class="voice">
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
</select>

<button>Computer, say the thing!</button>

              
            
!

CSS

              
                body {
  background-color: #F1C40F;
  text-align: center;
}

button {
  border: 20px solid white;
  margin: 30px;
  padding: 30px;
  color: white;
  font-size: 2rem;
  outline: none;
  cursor: pointer;
}

button {
  background-color: #2274A5;
}

input {
  border: 20px solid #D90368;
  margin: 30px;
  padding: 30px;
  color: #666;
  font-size: 2rem;
  outline: none;
  display: block;
  margin-left: auto;
  margin-right: auto;
  text-align: center
}


select {
  border: 20px solid #00CC66;
  margin-top: 30px;
  padding: 30px;
  color: #666;
  font-size: 2rem;
  outline: none;
  display: block;
  margin-left: auto;
  margin-right: auto;
}
              
            
!

JS

              
                const speak = async (text, lang, voiceIndex) => {
  const message = new SpeechSynthesisUtterance(text)
  
  message.voice = await chooseVoice(lang, voiceIndex)
  //...
  
  speechSynthesis.speak(message)
}

const chooseVoice = async (lang, voiceIndex) => {
  const voices = (await getVoices()).filter(voice => voice.lang === lang)
  return voices[voiceIndex]
}

const getVoices = () => {
  return new Promise((resolve) => {
    let voices = speechSynthesis.getVoices()

    if (voices.length) {
      resolve(voices)
      return
    }
    
    const voiceschanged = () => {
      voices = speechSynthesis.getVoices()
      resolve(voices)
    }
    
    speechSynthesis.onvoiceschanged = voiceschanged
  })
}


document.querySelector('button').addEventListener('click', () => {
  const text = document.querySelector('input').value
  if (!text) {
    alert('Enter some text!')
    return
  }
  
  const lang = document.querySelector('.language').value
  const voiceIndex = document.querySelector('.voice').value
  
  speak(text, lang, voiceIndex)
})
              
            
!
999px

Console