在不使用SSML的情况下向Alexa添加暂停

时间:2017-03-08 14:24:48

标签: c# alexa-voice-service

有没有办法在Amazon Alexa 中添加暂停(最好是1秒)而不使用SSML?也许我可以使用Outputspeech.Text做一个技巧而我只是不知道它。

下面,我说“这是{艺术家名字}的艺术作品”,但艺术作品的名称和起点混合在一起 - 尽管有时期 - 所以我最终得到像“这里是Pablo Picasso Harlequin的艺术作品......“

我使用的是C#和我自己的https端点,而不是AWS Lambda。

有什么建议吗?否则我会将其添加为SSML。感谢。

        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;

更新

行。结束了SSML路线,如下所示:

        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;
    }

1 个答案:

答案 0 :(得分:0)

如果没有SSML,没有办法在Alexa中引入暂停。您需要构建ssml字符串并使用pause或cadence字符串将其返回给Alexa。