Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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

              
                  <h1>Chat Audio experiments</h1>
        <div id="text-to-speech">
          <textarea id="text"></textarea>
        </div>
<button id="start">Record</button>
<button id="speak-button">Speak</button>

              
            
!

CSS

              
                .active {
  border: 2px solid red;
  background: red;
}

#text {
  width: 1200px;
  height: 200px;
  display: block;
}
              
            
!

JS

              
                //audio to text
const recognitionSvc = window?.SpeechRecognition || window?.webkitSpeechRecognition;
const recognition = new recognitionSvc();


document.querySelector('#start').addEventListener('click', ()=>{
    const startBtn = document.querySelector('#start');
    recognition.lang = 'en-GB';
    recognition.continuous = true;

    recognition.onresult = (event) => {
      const accumulatedResult = [];
      for (const result of event.results) accumulatedResult.push(`${result[0].transcript}`);

      document.querySelector('#text').innerHTML = accumulatedResult;
    };

    if(startBtn.classList.contains('listening')) recognition.stop();
    else recognition.start();

    startBtn.classList.toggle('listening');
});

document.querySelector('#start').addEventListener('click', (e) => {
  navigator.clipboard.writeText(e.target.innerText).then( () => {
    document.getElementById('text').classList.add('active');
    setTimeout( () => {
      document.getElementById('text').classList.remove('active');
    }, 3100);
  });
});

setTimeout( () => {
}, 3100);


//text to audio
// Get the text area and speak button elements
            let textArea = document.getElementById("text");
            let speakButton = document.getElementById("speak-button");

            // Add an event listener to the speak button
            speakButton.addEventListener("click", function() {
              // Get the text from the text area
              let text = textArea.value;

              // Create a new SpeechSynthesisUtterance object
              let utterance = new SpeechSynthesisUtterance();

              // Set the text and voice of the utterance
              utterance.text = text;
              utterance.voice = window.speechSynthesis.getVoices()[0];

              // Speak the utterance
              window.speechSynthesis.speak(utterance);
            });
              
            
!
999px

Console