How to convert Highlighted or Selected text to speech

Published on Author Code Father
How to convert selected text to speech? How to convert Highlighted text to speechText to speech in HTML5 ,JavaScript which runs on all browser. Selected text to speech which runs on all browser.Text to speech using Javascript.Text to speech using jquery.


<!DOCTYPE html>
<html lang="en" xmlns="">
 <meta charset="utf-8" />
 var text = '';
 function gText(e) {
 text = (document.all) ? document.selection.createRange().text : document.getSelection();

 document.getElementById('sel').value = text;
 var u1 = new SpeechSynthesisUtterance(document.getElementById("sel").value);
 u1.lang = 'en-US';
 u1.pitch = 1;
 u1.rate = 1;
 //u1.voice = voices[10];
 u1.voiceURI = 'native';
 u1.volume = 1;

 document.onmouseup = gText;
 if (!document.all) document.captureEvents(Event.MOUSEUP);
 <title> </title>
<textarea id="sel" rows="3" cols="50" style="display:none;"></textarea>
<h2>Welcome to Text to speach Demo. Please select below text.</h2>

<ul class="list">
<li><p><b>Import required modules</b> − We use the <b>require</b></p></li>
<li><p><b>Create server</b> − A server which will listen to client's requests similar</p></li>
<li><p><b>Read request and return response</b> − The server created in an earlier step will read the HTTP request made by the client which can be a browser or a console and return the response.</p></li>

 Run code snippetHide results <span style="color:red;">HWW</span>.
<p>i want to check if the particular word is exits or not in the string with ignore case.</p>

<p>My String is - "Hello world , Wassup? , good moRNING".</p>

<p>Now i want to check if the word - "hello world".</p>

<p>so i have tried the following:</p>

<p>I have also tried with <code>contains</code> but this is not working.</p>

<p>How can i find this particular word ?</p>