Someone’s message..
I am trying to create an object with TTS, please. It works as a function, but I cannot get it to work as an object.
`<BODY>
Enter Response: <input type=”text” id=”input”><br>
<button onclick=”MyFunction(input.value)”>Click Button</button>
<script>
function MyFunction(input) {
document.write(“<h1>You gave “+input+”</h1>”);
var x = input;
if (x == “w”) { speak(x); } // augument x is pass, originally from text box
}
const say = {
function speak(x) {
let msg = (“Hello” + x);
let speech = new SpeechSynthesisUtterance();
speech.lang = “en-US”; // Text Language
speech.text = msg; // The text you want to convert to speech
speech.volume = 1; // Volume
speech.rate = 1; // Speed
speech.pitch = 1; // Pitch
window.speechSynthesis.speak(speech);
}
}
};
// Display data from the object:
document.getElementById(“demo”).innerHTML = say.speak(x);
</script>
</BODY>`