Comments (2)
the above issue was resolved by doing this:
var synthesis = undefined;
var voice = undefined;
window.onload = function () {
var voiceElement = document.getElementById("myBtn");
// voiceElement.speak();
};
if ("speechSynthesis" in window) {
synthesis = window.speechSynthesis;
console.log("1");
// Regex to match all English language tags e.g en, en-US, en-GB
var langRegex = /^en(-[a-z]{2})?$/i;
console.log("2");
setTimeout(function () {
// Get the available voices and filter the list to only have English speakers
voice = synthesis.getVoices().filter(function (voice) {
return voice.uri === "Rishi";
})[0];
speakWord("welcome to digi vision");
// var voices = synthesis
// .getVoices()
// .filter((voice) => langRegex.test(voice.lang));
// Log the properties of the voices in the list
// voices.forEach(function (voice) {
// console.log({
// name: voice.name,
// lang: voice.lang,
// uri: voice.voiceURI,
// local: voice.localService,
// default: voice.default,
// });
// });
}, 300);
console.log("3");
} else {
console.log("Text-to-speech not supported.");
}
function speakWord(text) {
var utterance = new SpeechSynthesisUtterance(text);
// Set utterance properties
utterance.voice = voice;
utterance.pitch = 1.6;
utterance.rate = 1;
utterance.volume = 1.6;
console.log("4");
// Speak the utterance
synthesis.speak(utterance);
}
from web-speech-demo.
Can you share a sample of what your code looks like.
from web-speech-demo.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from web-speech-demo.