In this post we will show how to add text to speech support to your web pages , simplified steps will be followed for that.
We will use eSpeak which is open source project: http://espeak.sourceforge.net/
Link: http://espeak.sourceforge.net/
1) Create Java Web Application : (or HTML page)
2) Create folder JS and place the following files:
- speakWorker.js
- speakGenerator.js
- speakClient.js
3) Edit speakClient.js and change the 3rd line in the file to point to your JS folder :
speakWorker = new Worker('js/speakWorker.js');
4) Create JSP pages (or HTML page) :
a) Add the following JS imports in the header:
<script src="js/speakGenerator.js"></script>
<script src="js/speakClient.js"></script>
b) Add this function in the header as well:
<script>
function textToSpeech(text){
// you can change any of these voice characteristics
speak(text, { amplitude: 100, wordgap: 1, pitch: 50, speed: 175 });
}
</script>
c) Add this div to your page body :
<div id="audio"></div>
5) In your page use the function we have just created like this:
I have added small icon beside each filed to text to speech its content in human friendly way : Name is ..., City is ...., Country is ......
Name : <input type="text" name="name" id="name" size=50 value="Osama Oransa"><img src="images/tts.png" onclick="textToSpeech('Name is '+document.forms[0].name.value); return false" style="cursor:pointer;vertical-align: middle">
The nice thing in this open source project that it support a lot of languages and different voice with ability to tune each voice using many features and if you didn't find your language you can generate the speech generator for it.
We will use eSpeak which is open source project: http://espeak.sourceforge.net/
Link: http://espeak.sourceforge.net/
1) Create Java Web Application : (or HTML page)
2) Create folder JS and place the following files:
- speakWorker.js
- speakGenerator.js
- speakClient.js
3) Edit speakClient.js and change the 3rd line in the file to point to your JS folder :
speakWorker = new Worker('js/speakWorker.js');
4) Create JSP pages (or HTML page) :
a) Add the following JS imports in the header:
<script src="js/speakGenerator.js"></script>
<script src="js/speakClient.js"></script>
b) Add this function in the header as well:
<script>
function textToSpeech(text){
// you can change any of these voice characteristics
speak(text, { amplitude: 100, wordgap: 1, pitch: 50, speed: 175 });
}
</script>
c) Add this div to your page body :
<div id="audio"></div>
5) In your page use the function we have just created like this:
I have added small icon beside each filed to text to speech its content in human friendly way : Name is ..., City is ...., Country is ......
Name : <input type="text" name="name" id="name" size=50 value="Osama Oransa"><img src="images/tts.png" onclick="textToSpeech('Name is '+document.forms[0].name.value); return false" style="cursor:pointer;vertical-align: middle">
The nice thing in this open source project that it support a lot of languages and different voice with ability to tune each voice using many features and if you didn't find your language you can generate the speech generator for it.