Search code examples
nlpalexa-skills-kit

How does Alexa handle period vs comma (and other punctuation)


When writing an Alexa intent, I'm reading results from a list and if the entry matches a criteria, I append to the response. For example:

alist = ['Boston', 'New York', 'San Francisco', 'San Mateo', 'San Diego']
response = ''
for i in alist:
  if 'San' in i:
    response += i + '. ' # <-- Here lies my question

print(response)
# San Francisco. San Mateo. San Diego

As you can see, I'm using a "period" to separate my responses. When Alexa speaks out the response, I assume that a period has a slightly longer pause than a "comma", but I couldn't find any documentation.

Will Alexa pause longer or shorter if I use a comma instead of a period? What if it is a semicolon?


Solution

  • Actually, the pause after the punctuation is about the same, but Alexa says the words very differently. Like, the tone is totally different. She thinks that if there's a period, it's the end of a sentence, and her tone is lower. But if it's a comma, then the sentence isn't over yet, and the tone of the word is higher.

    You can very easily play around with Alexa's voice and find out for yourself. In the Alexa Developer Console, go to the test tab, then choose the Voice and Tone tab.

    You can read about Alexa's Speech Synthesis Markup Language (SSML) here: https://developer.amazon.com/docs/custom-skills/speech-synthesis-markup-language-ssml-reference.html