[trick] Text to Speech dengan responsivevoice.js ala google translate

Kali ini saya membagikan pengalaman saya dengan text ke suara dengan javascript. dulu saya mencoba dengan berbagai cara , dengan plugin flash terus google speach dll, seiring waktu berjalan sekarang makin banyak kemudahan untuk menterjemahkan text ke suara , salah satu caranya dengan responsivevoice.js

berikut kodenya:


<!DOCTYPE html>
<html>
<head>
<title>speak text to speech with Resvonsive Voice</title>
<script src='https://code.responsivevoice.org/responsivevoice.js'></script>
<script type="text/javascript">
function play (){
responsiveVoice.speak(
"Hallo Nama Saya RIfqi.",
"Indonesian Female",
{
pitch: 1,
rate: 1,
volume: 1
}
);
}

function stop (){
responsiveVoice.cancel();
}

function pause (){
responsiveVoice.pause();
}

function resume (){
responsiveVoice.resume();
}
</script>
</head>
<body>
<button onclick="play();">Play</button>
<button onclick="stop();">Stop</button>
<button onclick="pause();">Pause</button>
<button onclick="resume();">Resume</button>
</body>
</html>

catatan: gunakan langsung pada hostingan / vps anda karena akan berjalan dengan baik kalau live online.

semoga bermanfat 🙂

Advertisements
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: