{"id":2317,"date":"2017-06-06T12:39:40","date_gmt":"2017-06-06T04:39:40","guid":{"rendered":"https:\/\/www.csslayer.info\/wordpress\/?p=2317"},"modified":"2017-06-06T12:39:40","modified_gmt":"2017-06-06T04:39:40","slug":"shell-script-for-google-tts-on-plasma-desktop","status":"publish","type":"post","link":"https:\/\/www.csslayer.info\/wordpress\/kde\/shell-script-for-google-tts-on-plasma-desktop\/","title":{"rendered":"Shell script for Google TTS on Plasma desktop"},"content":{"rendered":"<p>My wife has extreme dry eye condition, so she want to avoid looking at the screen as much as possible. She asked me for a solution for Text-to-Speech on linux desktop.<\/p>\n<p>Basically her requirement is to press a key and read out what she selects. I check jovie, but that&#8217;s somehow discontinued and the only speech-dispatcher backend available on my distro is espeak, whose voice quality is poor comparing to any modern solution on the desktop.<\/p>\n<p>So I decided to check if there&#8217;s any available solution on internet and see if there&#8217;s a solution that using Google translate&#8217;s TTS service.<\/p>\n<p>So far I found a script from <a href=\"http:\/\/elinux.org\/RPi_Text_to_Speech_(Speech_Synthesis)#Google_Text_to_Speech\">http:\/\/elinux.org\/RPi_Text_to_Speech_(Speech_Synthesis)#Google_Text_to_Speech<\/a><\/p>\n<p>Which I adjusted a little for my usecase:<\/p>\n<pre>#!\/bin\/bash\r\n\r\nTEXT=$(xsel)\r\n\r\nsay() { local IFS=+;\/usr\/bin\/mplayer -really-quiet -noconsolecontrols \"http:\/\/translate.google.com\/translate_tts?ie=UTF-8&amp;client=tw-ob&amp;q=$*&amp;tl=en\"; }\r\nsay $TEXT<\/pre>\n<p>I added xsel for reading string from primary selection, which is exactly what she&#8217;s asking for. And then I use plasma&#8217;s convenient custom global shortcut to bind a key to this script. Then you can enjoy the google tts with a single key press.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My wife has extreme dry eye condition, so she want to avoid looking at the screen as much as possible. She asked me for a solution for Text-to-Speech on linux desktop. Basically her requirement is to press a key and &hellip; <a href=\"https:\/\/www.csslayer.info\/wordpress\/kde\/shell-script-for-google-tts-on-plasma-desktop\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[194],"class_list":["post-2317","post","type-post","status-publish","format-standard","hentry","category-kde","tag-planetkde"],"_links":{"self":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts\/2317","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/comments?post=2317"}],"version-history":[{"count":1,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts\/2317\/revisions"}],"predecessor-version":[{"id":2318,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/posts\/2317\/revisions\/2318"}],"wp:attachment":[{"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/media?parent=2317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/categories?post=2317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.csslayer.info\/wordpress\/wp-json\/wp\/v2\/tags?post=2317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}