<input type="text" id="msg">
<button id="btn">Speech</button>
<script type="text/javascript">
let speech = new SpeechSynthesisUtterance();
speech.lang = 'en';
btn.onclick = function(){
speech.text = msg.value;
window.speechSynthesis.speak(speech);
}
</script>