Search code examples
c#alexa-voice-service

Add pause to Alexa without using SSML


Is there a way to add a pause (preferably 1 second) in Amazon Alexa without using SSML? Perhaps there is a trick I can do with the Outputspeech.Text and I just don't know it.

Below, I am saying "Here are works of art by {artist name}" but the name and the start of the works of art become mixed together - in spite of the period - so I end up with things like "Here are the works of art by Pablo Picasso Harlequin..."

I am using C# and my own https endpoint, not AWS Lambda.

Any suggestions? Otherwise I will add it as SSML. Thanks.

        var output = new StringBuilder();
        var outputCard = new StringBuilder();

        string m_location;
        string m_current_location;

        string m_artist = dt_artist.Rows[0]["DisplayName"].ToString();

        output.Append("here are works of art for " + m_artist + ". ");
        outputCard.Append("Here are works of art for " + m_artist + ".\n\n");

        foreach (DataRow dr in dt_artist_objs.Rows)
        {
            m_current_location = dr["CurrentLocation"].ToString();

            if (m_current_location == " ")
            {
                m_location = "The location is not available.";
            }
            else
            {
                m_location = "It is located on the " + m_current_location;
            }

            output.Append(dr["Title"].ToString() + " is a " + dr["Classification"].ToString() + ". The medium is " + dr["Medium"].ToString() + ". " + m_location); 
            outputCard.Append(dr["Title"].ToString() + ", " + dr["Dated"].ToString() + " is a " + dr["Classification"].ToString() + ". The medium is " + dr["Medium"].ToString() + ". " + dr["Creditline"].ToString() + ". " + m_location + ".\n");  // It is located on the " + dr["CurrentLocation"].ToString());

        }

        sql_conn_data.Close();

        response.Response.OutputSpeech.Text = output.ToString();
        response.Response.Card.Title = "Art";
        response.Response.Card.Type = "Standard";
        response.Response.Card.Text = outputCard.ToString();
        response.Response.ShouldEndSession = true;

        return response;

UPDATE

OK. Ended up going the SSML route which looks like this:

        var output = new StringBuilder();
        var outputCard = new StringBuilder();

        string m_location;
        string m_current_location;
        string m_location_card;

        string m_artist = dt_artist.Rows[0]["DisplayName"].ToString();

        output.Append("<speak>");
        output.Append("here are works of art for " + m_artist + ". <break time='1s'/> ");
        outputCard.Append("Here are works of art for " + m_artist + ".\n\n");

        foreach (DataRow dr in dt_artist_objs.Rows)
        {
            m_current_location = dr["CurrentLocation"].ToString();

            if (m_current_location == " ")
            {
                m_location = "The location is not available. <break time='1s' />";
                m_location_card = "The location is not available. ";
            }
            else
            {
                m_location = "It is located on the " + m_current_location + "<break time = '1s' />";
                m_location_card = "It is located on the " + m_current_location;
            }

            output.Append(dr["Title"].ToString() + " is a " + dr["Classification"].ToString() + ". The medium is " + dr["Medium"].ToString() + ". " + m_location); 
            outputCard.Append(dr["Title"].ToString() + ", " + dr["Dated"].ToString() + " is a " + dr["Classification"].ToString() + ". The medium is " + dr["Medium"].ToString() + ". " + dr["Creditline"].ToString() + ". " + m_location_card + ". \n"); 

        }

        output.Append("</speak>");

        sql_conn_data.Close();

        response.Response.OutputSpeech.Ssml = output.ToString();
        response.Response.OutputSpeech.Type = "SSML";
        response.Response.Card.Title = "Art";
        response.Response.Card.Type = "Standard";
        response.Response.Card.Text = outputCard.ToString();
        response.Response.ShouldEndSession = true;

        return response;
    }

Solution

  • There is not a way to introduce a pause in Alexa without SSML. You will need to build the ssml string and return it back to Alexa using the pause, or the cadence strings.