Author Topic: Learning Arabic with Voxcommando  (Read 19856 times)

0 Members and 1 Guest are viewing this topic.

rio14

  • Contributor
  • ***
  • Posts: 59
  • Karma: 4
    • View Profile
Re: Learning Arabic with Voxcommando
« Reply #30 on: June 20, 2016, 03:01:55 PM »
hi nim
according to arabic translation  i wanted  display text like   english word=arabic translation   i used last result but does not working because it takes the result of the prevouise command how to fix it thank you

 
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.1.9-->
<commandGroup open="False" name="translation en to ar" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="430" 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="409" 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="510" name="translate" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="40" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>google.tts</param>
        <param>{1}</param>
        <param>ar</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.Pause</cmdType>
      <params>
        <param>2000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{1} = {lastresult}</param>
        <param>10000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>say</phrase>
    <payloadDictation>payloadDictation: Regular</payloadDictation>
  </command>
</commandGroup>

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Learning Arabic with Voxcommando
« Reply #31 on: June 20, 2016, 04:01:12 PM »
Hi Rio,

1. Remember to be careful with your 2 Google.TTS commands. If you try to create new commands that are triggered with the same events and command names that you already use for your text-to-speech, you will have many problems.

2. Your {LastResult} did not work because your Google.TTS command was not originally designed to capture and store the Arabic text in VoxCommando.

The original Google.TTS RoboBrowser command works by literally typing the text that you want spoken aloud on the Google Translate webpage, and then automatically clicking on the "Listen" button that appears on that page. The RoboBrowser window is hidden, so we don't see it. The audio is coming from the hidden RoboBrowser window.

3. In this case, you want to display the English text and its Arabic translation. That requires that we actually capture the Arabic text from the hidden RoboBrowser window, so that we can use it in VoxCommando.

i. First we need to select the correct field ("Element") on the Google Translate page. To find the correct element, we need to "show" the RoboBrowser window temporarily so that we can see what is happening.

Now we can use our RoboBrowser "Investigator" Tool to find the ID for that text field. We discover that the ID is called "result_box".

[See attached image]

ii. Once we've selected that element in our command, we can capture the text in "result_box", using the action RoboB.GetText.

iii. That text will now be stored in {LastResult}.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.1.9-->
<commandGroup open="True" name="translation en to ar" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="430" name="Translate English to Arabic" 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>GoogleTranslateEn2Ar</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>GoogleTranslate</event>
  </command>
  <command id="409" name="GoogleTranslation page loaded" 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>GoogleTranslateEn2Ar</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.ElementByID</cmdType>
      <params>
        <param>result_box</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>RoboB.GetText</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>LastActionSuccess</ifType>
      <ifParams>&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <params>
            <param>{var.EnglishText} = {LastResult}</param>
            <param>10000</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <params>
            <param>Translation unsuccessful.</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <event>RoboB.DocComplete.GoogleTranslateEn2Ar</event>
  </command>
  <command id="542" name="translate" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="40" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <params>
        <param>GoogleTranslate</param>
        <param>{1}</param>
        <param>ar</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>EnglishText</param>
        <param>{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>say</phrase>
    <payloadDictation>payloadDictation: Regular</payloadDictation>
  </command>
</commandGroup>

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)

rio14

  • Contributor
  • ***
  • Posts: 59
  • Karma: 4
    • View Profile
Re: Learning Arabic with Voxcommando
« Reply #32 on: June 21, 2016, 02:27:11 PM »
thank you nim
it's a little thing but needs a big job

Powers

  • Jr. Member
  • **
  • Posts: 11
  • Karma: 3
    • View Profile
Re: Learning Arabic with Voxcommando
« Reply #33 on: December 13, 2020, 10:12:40 AM »
The website http://praytimes.org/ provides code in various programming languages to calculate prayer times depending on your location, including in Python. I was able to use their code without any problems using VC's Python plugin...

Hello all! I was interested in VC about a year ago this week, however, never dived in until now. Browsing thru the forums and found this to be pretty neat. I know its been years and both this forum thread and website haven't been updated in a while. I am not good with python and tried first myself and couldn't get the offset/adjust to work. The VC shows the time when it loads and my fajr and isha times are off. Fajr is early by 24 minutes and isha late by 15 minutes.

@nime5ter (or anyone else who is better at python then me, meaning everyone else!) I tried to place this in many different location but with no success. May I get assistance please?

prayTimes.adjust( {fajr: 24, isha: -15} );

Thank you an advance!

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Learning Arabic with Voxcommando
« Reply #34 on: December 13, 2020, 11:48:26 AM »
Greetings and welcome to the forum.

The calculations do seem to be off, thanks for pointing it out. I will take a look at the Python to try to figure out what's up. I'll try to post a response some time this week.
« Last Edit: December 14, 2020, 09:44:09 AM by jitterjames »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Learning Arabic with Voxcommando
« Reply #35 on: December 14, 2020, 10:56:24 AM »
The VC shows the time when it loads and my fajr and isha times are off. Fajr is early by 24 minutes and isha late by 15 minutes.

What calculation method are you using?  I think the code defaults to Egyptian and we may need to specify ISNA?

Powers

  • Jr. Member
  • **
  • Posts: 11
  • Karma: 3
    • View Profile
Re: Learning Arabic with Voxcommando
« Reply #36 on: December 17, 2020, 10:52:40 AM »
Hi jitterjames

I set calcMethod = 'ISNA' and timeFormat = '12h'. I am in Washington DC. I set the coordinate as 38.89, -77.04, exact string is, "myPrayTimes(38.89, -77.04,-5)" for the action, "PY.ExecString". I have attached a photo of the executed times but Fajr should be around 6am and Isha around 6pm

Was there other argument/parameters I needed to set?

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Learning Arabic with Voxcommando
« Reply #37 on: December 18, 2020, 12:02:24 PM »
At this point I really don't know what code you are using, or how you determine if the times generated are correct, but the attached code seems to be correct (as far as I can tell) so you may want to give it a try.

Powers

  • Jr. Member
  • **
  • Posts: 11
  • Karma: 3
    • View Profile
Re: Learning Arabic with Voxcommando
« Reply #38 on: December 19, 2020, 07:48:04 PM »
Yup, that was it, my file was messed up. But really it turns out the line you added at the bottom did the trick. Which is weird, means the python variable for "calcMethod" does not work for VC.

The line:
    prayTimes.setMethod('ISNA');

Thank you @jitterjames

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Learning Arabic with Voxcommando
« Reply #39 on: December 21, 2020, 05:01:19 PM »
Yup, that was it, my file was messed up. But really it turns out the line you added at the bottom did the trick. Which is weird, means the python variable for "calcMethod" does not work for VC.

The line:
    prayTimes.setMethod('ISNA');

Thank you @jitterjames

I think it's just a matter of how and when you set the variable and if that results in valid Python code.  I just followed some online guides and they suggested using that method so that's what I did.