Coder Social home page Coder Social logo

Comments (9)

glittle avatar glittle commented on May 31, 2024 2

All I needed was to read out numbers, so I got what I needed by doing 'my number'.split('').join(' ') and it correctly reads the numbers for me.

from actions-on-google-nodejs.

smishra2 avatar smishra2 commented on May 31, 2024

Yes you're correct that you need to wrap your entire spoken statement in open and close tags (i.e., <speak>...</speak>). As for the say-as tags, what you have (assistant.ask('<speak>We found Product <say-as interpret-as=\"characters\">ABC1</say-as> - Bottle</speak>')) should work. I just tested in the web sim and got the expected result. Try putting this string directly in APIAI as a text response and see if it works there, that might be helpful to debug.

from actions-on-google-nodejs.

ds8k avatar ds8k commented on May 31, 2024

API.AI has no problem reading the string.

// Google Home says: "We found Product Bottle"
assistant.tell('<speak>We found Product <say-as interpret-as=\"characters\">ABC1</say-as> - Bottle</speak>');

Response: {
  "response": "We found Product<unknown word to simulator>- Bottle\n",
    "debugInfo": {
      "agentToAssistantDebug": {
        "agentToAssistantJson": {
          "conversation_token": "[]",
            "expect_user_response": false,
            "final_response": {
              "rich_response": {
                "items": [{
                    "simple_response": {
                        "ssml": "<speak>We found Product <say-as interpret-as=\"characters\">ABC1</say-as> - Bottle</speak>"
                    }
                }]
              }
            }
          }
      }
    }
}

from actions-on-google-nodejs.

smishra2 avatar smishra2 commented on May 31, 2024

Hi @ds8k, sorry for the late response on this. I think the issue might be that the SSML transducer doesn't understand 'ABC1' as a character string. Just 'ABC' does work. Try moving the '1' outside the say-as tags. In my testing, I didn't need the say-as tags at all.

from actions-on-google-nodejs.

Swivelgames avatar Swivelgames commented on May 31, 2024

@smishra2 That sounds like it would become a major problem, especially if "ABC1" is being pulled from a database or outside source of some sort...

from actions-on-google-nodejs.

nominator avatar nominator commented on May 31, 2024

Any update on this one @ds8k @smishra2 ? I have a long number that I want Google Assistant to speaks as individual digits and it is giving me same 'unknown word to simulator' error. It is strange @smishra2 if it does not work with numbers because example on official actions documentation uses numbers. Here is the link

from actions-on-google-nodejs.

Swivelgames avatar Swivelgames commented on May 31, 2024

@ds8k @nominator A temporary alternative may be to use a utility function to generate the tags that you need, at least until this bug is acknowledged and fixed.

Something similar to this maybe?

const sayAsCharacters = (text) => {
    let ret = '';
    let chars = text.split('');
    let c = '';
    while(c = chars.shift()) {
        let prevChar = ret.slice(-1);
        if (isNaN(parseInt(c))) {
            if (!isNaN(parseInt(prevChar)) || !prevChar) {
                ret += ` <say-as interpret-as="characters">`;
            }
            ret += c;
            if (chars.length === 0) ret += `</say-as> `;
        } else {
            if (isNaN(parseInt(prevChar))) ret += `</say-as> ${c}`;
            else ret += ` ${c}`;
        }
    }
    return ret;
};

The above produces the following:

sayAsCharacters('foo12bar');
" <say-as interpret-as="characters">foo</say-as> 1 2 <say-as interpret-as="characters">bar</say-as> "

from actions-on-google-nodejs.

glittle avatar glittle commented on May 31, 2024

I've got a number like 982968761 that I want to have read as characters: 9 8 2 9 6... not "nine hundred eighty two million, ..."

Using this should work, but doesn't:

<speak>
The code is:  <say-as interpret-as="characters">982968761</say-as>
</speak>

from actions-on-google-nodejs.

Swivelgames avatar Swivelgames commented on May 31, 2024

@glittle Please see my solution and let me know if it works for you.

from actions-on-google-nodejs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.