Author Topic: Poor man's (or woman's) TTS - streaming Google Text-To-Speech  (Read 10150 times)

0 Members and 1 Guest are viewing this topic.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
I'm actually not sure if there is already some xml on the forum for this somewhere, but here it is in a nice neat, easy to use package.

If you don't have a TTS voice in your language you can use this to speak in many different languages.

This group provides two commands.  The first is an event driven command to make calling the TTS easy.  The second is a sample command that uses the first.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.5.0-->
<commandGroup open="True" name="Google TTS Streaming" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="286" name="Google.TTS" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="triggered by an event expecting 2 payloads&#xD;&#xA;{1} text to speech&#xD;&#xA;{2} language code">
    <action>
      <cmdType>Sound.PlayStream</cmdType>
      <params>
        <param>http://translate.google.com/translate_tts?tl={2}&amp;q={1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>Google.TTS</event>
  </command>
  <command id="283" name="++ Speak to me google" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>Google.TTS</param>
        <param>greetings earth being</param>
        <param>en</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>2500</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>Google.TTS</param>
        <param>bonjour mon ami</param>
        <param>fr</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>3000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>Google.TTS</param>
        <param>guten tag mein herr</param>
        <param>de</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>3000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>Google.TTS</param>
        <param>Buongiorno! Come stai?</param>
        <param>it</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Speak to me google</phrase>
  </command>
</commandGroup>

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Poor man's (or woman's) TTS - streaming Google Text-To-Speech
« Reply #1 on: July 17, 2015, 04:59:50 AM »
 :clap
adding it to the Gems ...
When Voice command gets tough, use hand gestures

yokel

  • Jr. Member
  • **
  • Posts: 26
  • Karma: 2
    • View Profile
Re: Poor man's (or woman's) TTS - streaming Google Text-To-Speech
« Reply #2 on: August 17, 2015, 07:28:26 PM »
Google seems to have killed this with a captcha.

sainf

  • $upporter
  • Jr. Member
  • *****
  • Posts: 20
  • Karma: 0
  • Living In Ireland
    • View Profile
Re: Poor man's (or woman's) TTS - streaming Google Text-To-Speech
« Reply #3 on: October 25, 2015, 10:58:35 AM »
sorry to bother.
Just want to know if anyone has updated command or how to integrate google translate into mix.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Poor man's (or woman's) TTS - streaming Google Text-To-Speech
« Reply #4 on: October 25, 2015, 11:35:28 AM »
Sorry, do you mean specifically in order to use Google Translate as a TTS voice, or are you asking if anyone has a command that translates text from one language to another?
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Poor man's (or woman's) TTS - streaming Google Text-To-Speech
« Reply #5 on: October 25, 2015, 12:08:14 PM »
Google cannot defeat us.  Not when we have the power of the RoboBrowser on our side!

This works... for now anyway :)

Translation and TTS all in one...  If it seems to work it will remain hidden, otherwise it will show the window to aid in debugging.

Don't forget that you need to enable the RoboB plugin for this command to work.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.0.9-->
<commandGroup open="True" name="Google TTS Streaming" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="286" name="Call Google.TTS" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="triggered by an event expecting 2 payloads&#xD;&#xA;{1} text to speech&#xD;&#xA;{2} language code">
    <action>
      <cmdType>RoboB.Select</cmdType>
      <params>
        <param>GoogleTranslate</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.Navigate</cmdType>
      <params>
        <param>https://translate.google.com/#en/{2}/{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>Google.TTS</event>
  </command>
  <command id="311" name="Google.TTS ready" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="triggered by an event expecting 2 payloads&#xD;&#xA;{1} text to speech&#xD;&#xA;{2} language code">
    <action>
      <cmdType>RoboB.Select</cmdType>
      <params>
        <param>GoogleTranslate</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.ElementByID</cmdType>
      <params>
        <param>gt-res-listen</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>LastActionSuccess</ifType>
      <ifParams>&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>RoboB.Click</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>RoboB.Hide</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>RoboB.Show</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <event>RoboB.DocComplete.GoogleTranslate</event>
  </command>
  <command id="283" name="++ Speak to me google" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>Google.TTS</param>
        <param>greetings earth being</param>
        <param>en</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>2500</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>Google.TTS</param>
        <param>bonjour mon ami</param>
        <param>fr</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>3000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>Google.TTS</param>
        <param>guten tag mein herr</param>
        <param>de</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>3000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>Google.TTS</param>
        <param>Buongiorno! Come stai?</param>
        <param>it</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Speak to me google</phrase>
  </command>
</commandGroup>
« Last Edit: October 25, 2015, 12:11:33 PM by jitterjames »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Poor man's (or woman's) TTS - streaming Google Text-To-Speech
« Reply #6 on: June 22, 2016, 12:51:55 PM »
How this RoboBrowser TTS command group works:

1. You are providing:

i. the text that you want read aloud (and/or translated)
ii. the language that you want Google Translate to translate your text to, before reading it aloud.

2. The first command navigates to the Google Translate webpage, using the URL:
Code: [Select]
https://translate.google.com/#en/[languagecode of your choice]/[The text that you want read aloud (and/or translated)]/
3. When that web page is fully loaded, a RoboB.DocComplete.GoogleTranslate event is automatically generated in VC, and that triggers the 2nd command.

(Sidenote: the "GoogleTranslate" suffix in this event name comes from the fact that the first command names the RoboBrowser window it creates "GoogleTranslate". If you were to change that name, then the event generated would change accordingly. You will see this if you explore the 2 commands on your own.)

4. Note that now the Google Translate page has the original text in the left-hand box, and the translated text in the right-hand box.

If you provide English text, and "en" as the language code, then Google will "translate" the text from English to English, and the resulting text that is read aloud will still be English.

If you provide English text, and "fr" as the language code, then Google will translate the text from English to French, and the resulting text that is read aloud will be French. (etc.)

5. The second command uses RoboBrowser's functionality to select the "listen" button below the resulting text box, and then click on that button.

So the audio TTS that you hear is coming from this RoboBrowser window. The browser window is simply hidden.

If you want to do anything else with the resulting translation, you will need to actually capture the text. Currently, this command group does nothing but load a web page and click a button.
« Last Edit: June 22, 2016, 01:09:12 PM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Voxy

  • Jr. Member
  • **
  • Posts: 13
  • Karma: 1
    • View Profile
Re: Poor man's (or woman's) TTS - streaming Google Text-To-Speech
« Reply #7 on: October 17, 2016, 09:32:07 AM »
@nime5ter:

Thanks for in detail, step by step explaining the different parts and actions of the command group. I've seen you doing it in other posts too, it's really helpful.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Poor man's (or woman's) TTS - streaming Google Text-To-Speech
« Reply #8 on: October 17, 2016, 11:01:16 AM »
Hi Voxy,

That's great to hear, thanks for speaking up.

Some folks feel overwhelmed by long posts, so it's always a risk. With all the command xml posted on the forum, it's perhaps too easy to just copy and paste without understanding what's happening. 

I try to write my posts as though I'm the one who will be learning from them. I'm glad to know that some users are finding it helpful.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Poor man's (or woman's) TTS - streaming Google Text-To-Speech
« Reply #9 on: July 24, 2019, 04:32:14 AM »
@ nime5ter: I noticed the command above need a update - Goggle has changed the element-Tag. You are able to fix it much faster as I can.



One other thing:
I'm not sure it affects everyone, but in my case the RoboB.Navigate action does not create the RoboB.DocComplete-Event after loading the webpage (VC Version 2.2.4.5)


Thanks in advanced,
Kalle


(I've checked this function because some new members has visit this page)
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Poor man's (or woman's) TTS - streaming Google Text-To-Speech
« Reply #10 on: July 24, 2019, 08:25:19 AM »

One other thing:
I'm not sure it affects everyone, but in my case the RoboB.Navigate action does not create the RoboB.DocComplete-Event after loading the webpage (VC Version 2.2.4.5)

I just noticed this myself yesterday when playing with robobrowser. I'm not sure when it started but I will investigate.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Poor man's (or woman's) TTS - streaming Google Text-To-Speech
« Reply #11 on: July 24, 2019, 01:53:55 PM »
Hi Kalle,

Can you please test with this new version of the plugin.  I also fixed some issues with crashing when using the investigator (I hope...)

I've also created a new version of this command group.  It uses the "auto-detect" feature of Google translate so you don't have to specify the language.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.5.0-->
<commandGroup open="True" name="Google TTS Streaming" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="303" name="Call Google.TTS" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="triggered by an event expecting 2 payloads&#xD;&#xA;{1} text to speech&#xD;&#xA;{2} language code">
    <action>
      <cmdType>RoboB.Select</cmdType>
      <params>
        <param>GoogleTranslate</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.Navigate</cmdType>
      <params>
        <param>https://translate.google.com/#view=home&amp;op=translate&amp;sl=auto&amp;tl=fr&amp;text={1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>Google.TTS</event>
  </command>
  <command id="321" name="Click speaker to speak after load" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="triggered by an event expecting 2 payloads&#xD;&#xA;{1} text to speech&#xD;&#xA;{2} language code">
    <action>
      <cmdType>RoboB.Select</cmdType>
      <params>
        <param>GoogleTranslate</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.ElementByXY</cmdType>
      <params>
        <param>35</param>
        <param>309</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.Click</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>RoboB.DocComplete.GoogleTranslate</event>
  </command>
  <command id="300" name="++ Speak to me google" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>Google.TTS</param>
        <param>greetings earth being</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>2500</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>Google.TTS</param>
        <param>bonjour mon ami</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>3000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>Google.TTS</param>
        <param>guten tag mein herr</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>3000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>Google.TTS</param>
        <param>Buongiorno! Come stai?</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Speak to me google</phrase>
  </command>
</commandGroup>

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Poor man's (or woman's) TTS - streaming Google Text-To-Speech
« Reply #12 on: July 25, 2019, 04:54:52 AM »
Hi James,


good job  ::bow :yay


Now everything works (good to know is was not my PC which caused the investigator crash).


I noticed another issue in the RoboB plugin - if you use the gear wheel in the Investigator to copy a action in the VC command builder - it does generate each time also a RoboB.Select action too.


Maybe it is possible to use this Google TTS https://cloud.google.com/text-to-speech/
All the TTS voices sounding really good.
I have tried to use the RoboB browser to control this website, but it doesn't show all elements.



« Last Edit: July 25, 2019, 05:16:25 AM by Kalle »
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Poor man's (or woman's) TTS - streaming Google Text-To-Speech
« Reply #13 on: July 25, 2019, 10:30:59 AM »
I noticed another issue in the RoboB plugin - if you use the gear wheel in the Investigator to copy a action in the VC command builder - it does generate each time also a RoboB.Select action too.

This is done intentionally.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Poor man's (or woman's) TTS - streaming Google Text-To-Speech
« Reply #14 on: July 25, 2019, 10:57:01 AM »
Maybe it is possible to use this Google TTS https://cloud.google.com/text-to-speech/
All the TTS voices sounding really good.
I have tried to use the RoboB browser to control this website, but it doesn't show all elements.

Yeah, these voices do sound great, but it's not free and it does not seem to work in Internet Explorer at all so it will never work in RoboBrowser.