Giter Club home page Giter Club logo

text-to-speech's Introduction

How is this work :

The function PopulateVoices() is called, which populates the voices array with the available speech synthesis voices. If the browser supports speech synthesis, speechSynthesis.onvoiceschanged event listener is triggered to populate the voices array on voice changes.

When the btnSpeak button is clicked, an event listener is triggered. This event listener creates a new SpeechSynthesisUtterance using the text from txtInput.value It then selects the voice from voiceList.selectedOptions based on its name by iterating over the voice array using forEach, and comparing the name of the voice with selectedVoiceName

Once the appropriate voice is found, it sets the voice property of the SpeechSynthesisUtterance object to the selected voice, and finally initiates the speech outpt using synth.speak(toSpeak).

Finally, the PopulateVoices() function loops through the voices array to create a set of option elements for the voiceList dropdown menu. Each option element is created using document.createElement() to create an option tag, which is then appended to the voiceList using voiceList.appendChild() The new option tag is then populated with the name of the voice, as well as the specific lang and name details Once all the available voices are added to the dropdown menu, the previously selected option index value is set as the selected index using voiceList.selectedIndex = selectedIndex

CodePen :

https://codepen.io/Mo61n/pen/ZEMRjew

text-to-speech's People

Contributors

mo61n avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.