Text2Speech Bookmarklet

Jude Igot

Source (gist.github.com)


Download Bookmarklet:


View Bookmarklet Code:

Bookmarklet Source Code:

javascript%3A%20%20%20/*%20Text%20to%20Speech%20function.%20Adjust%20the%20value%20of%20msg.rate%20to%20increase/decrease%20the%20playback%20speed.%20*/%20const%20runTTS%20%3D%20_%20%3D%3E%20%7B%20%20%20/*%20Stop%20any%20currently%20playing%20TTS%20and%20empty%20the%20queue%20*/%20%20%20speechSynthesis.cancel%28%29%3B%20%20%20%20const%20msg%20%3D%20new%20SpeechSynthesisUtterance%28%29%3B%20%20%20msg.rate%20%3D%202.75%3B%20/*%20defaults%20to%201%20*/%20%20%20msg.text%20%3D%20window.getSelection%28%29.toString%28%29%3B%20%20%20speechSynthesis.speak%28msg%29%3B%20%7D%3B%20%20/*%20Speak%20the%20current%20seleciton%20when%20the%20user%20presses%20Ctrl+S%20%20*/%20document.addEventListener%28%27keydown%27%2C%20e%20%3D%3E%20%7B%20%20%20if%20%28e.key%20%3D%3D%3D%20%27s%27%20%26%26%20e.ctrlKey%29%20%7B%20runTTS%28%29%3B%20%7D%20%7D%29%3B%20%20/*%20Start%20speaking%20the%20current%20selection%20if%20text%20is%20selected%20when%20the%20bookmarklet%20is%20run%20*/%20if%20%28window.getSelection%28%29.toString%28%29%29%20%7B%20%20%20runTTS%28%29%3B%20%7D


Rate it:


Tags:

Comments

Comments so far. Add yours.