<say-as> tag currency in Spanish

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

  • Author
  • Message
Offline

averlan

  • Posts: 30
  • Joined: Thu Sep 21, 2017 8:24 pm

<say-as> tag currency in Spanish

PostFri May 31, 2019 3:30 pm

Hi,

I have checked several past posts regarding the issue of currency not spoken correctly in Spanish when using text-to-speech. One of the solutions suggested was in this post - viewtopic.php?f=2&t=72652&p=141759&hilit=spanish+currency#p141759. Do you have an example on how to preparse the currency amount on our end? Or please let me to know if this issue has since been resolved?

Thank you!
Offline

support

  • Posts: 3617
  • Joined: Mon Jun 02, 2003 3:47 pm
  • Location: Boston, MA

Re: <say-as> tag currency in Spanish

PostMon Jun 03, 2019 12:12 pm

Hello,

Sure thing! Please refer below for an example on how to preparse the currency amount:
Code: Select all
<prompt>
   <speak xml:lang="es_us"><say-as type="currency">$<value expr="dollar"/></say-as> y <value expr="cents"/> centavos. </speak>
</prompt>

Please let us know if you have any further questions.

Regards,
Plum Support
Offline

averlan

  • Posts: 30
  • Joined: Thu Sep 21, 2017 8:24 pm

Re: <say-as> tag currency in Spanish

PostMon Jun 03, 2019 2:16 pm

Thanks for your response. I'm not sure if I'm following your example. It says -xml:lang="es_us" - shouldn't it be "es-MX"?

Also, I just wanted to clarify that I need an example for one of your suggestion in the earlier post, you said: "You will need to preparse the currency amount on your end of the IVR code into "dos dólares y cincuenta centavos" since you cannot rely on the TTS engine to properly translate the amount into Spanish". Are we on the same page?

So I tried using your example something like this:

<prompt>
<speak xml:lang="es-MX">
<say-as type="currency">
$1500
<value expr="dollar"/>
</say-as>
75
<value expr="cents"/>
centavos.
</speak>
</prompt>

and I'm getting this error below:

Audio segment from the URL audio\F_S_PastDueBalance.wav added to prompt queue
ReferenceError: dollar is not defined line 1
received event: error.semantic.ecmascript
bargein set to true
INPUTMODES set to "DTMF"
Audio segment added to prompt queue from TTS application/synthesis+ssml for:
---------

Please advise
Offline

support

  • Posts: 3617
  • Joined: Mon Jun 02, 2003 3:47 pm
  • Location: Boston, MA

Re: <say-as> tag currency in Spanish

PostMon Jun 03, 2019 3:29 pm

Hello,

Both es_us and es-MX can be used as spanish TTS voices, depending on the voice you require. es_us is more commonly used within the US, whereas es-MX is catered for Mexican Spanish.

Pre-parsing could be done outside the vxml code by splitting the amount. Here's an example of parsing the balance of 32.50 into 32 dollar and 50 cents. In this case, once the balance has been separated into 32 and 50, you can add those into the vxml code using the <value> tag.
Code: Select all
<?php
echo "<?xml version=\"1.0\" encoding=\"latin-1\"?>";
$balance = '32.50';
$parsed = explode('.',$balance);
if(strlen($parsed[1]) == 1){$parsed[1] = $parsed[1]+"0"; }
$dollar = $parsed[0];
$cent = $parsed[1];
?>

<vxml version="2.0">
  <form id="form"> 
    <block>
      <var name='cent' expr="<?= $cent?>"/>
      <prompt>
         <speak xml:lang="es-us"><say-as type="currency">$<value expr="<?= $dollar?>"/></say-as> y <value expr="cent"/> centavos.</speak>
      </prompt>
    </block>
  </form>
</vxml>


The error you're getting means that there weren't any value assigned to the variable 'dollar'. In vxml, the tag <value> is used to show a variable. In the case you presented, you wouldn't need to include the <value> tag because the dollar and cent around were already part of the vxml script ($1500, 75). So in your case, you would only need
Code: Select all
<prompt>
         <speak xml:lang="es-us"><say-as type="currency">$1500</say-as> y 75 centavos.</speak>
</prompt>


Please let us know if you have any other questions!

Regards,
Plum Support

Return to Plum DEV Q&A

Who is online

Users browsing this forum: No registered users and 1 guest

cron