Exemple #1
0
        public void CreateAndVerifyGetSpeechStatusCallbackDigitRecognitionTest()
        {
            GetSpeechActionCallback getSpeechStatusCallback = GetSpeechActionCallback.fromJson("{\"accountId\":\"ACe1006ad515dbfc486dcb75d08db1445b928aef08\",\"callId\":\"CA2a98e2a2635c7cbd610d1085099a6c73e8990c7a\",\"callStatus\":\"inProgress\",\"conferenceId\":null,\"confidence\":92,\"direction\":\"outboundAPI\",\"from\":\"+12248806205\",\"parentCallId\":null,\"queueId\":null,\"reason\":\"recognition\",\"requestId\":\"RQc6a43de7b417b7c77b6a1e3c27628bb83c86c6ca\",\"requestType\":\"getSpeech\",\"recognitionResult\":\"3 3 3\",\"to\":\"+18475978014\"}");

            Assert.AreEqual(getSpeechStatusCallback.getRecognitionResult, "3 3 3");
            Assert.AreEqual(getSpeechStatusCallback.getReason, ESpeechTermReason.Recognition);
            Assert.AreEqual(getSpeechStatusCallback.getConfidence, 92);
        }
Exemple #2
0
        public ActionResult SelectColorDone(GetSpeechActionCallback getSpeechStatusCallback)
        {
            // Create an empty PerCL script container
            PerCLScript script = new PerCLScript();

            // Check if recognition was successful
            if (getSpeechStatusCallback.getReason == ESpeechTermReason.Recognition)
            {
                // Create PerCL say script with US English as the language
                Say say = new Say();
                say.setLanguage(ELanguage.EnglishUS);
                // Set prompt to speak the selected color
                say.setText(string.Format("Selected color was {0}", (getSpeechStatusCallback.getRecognitionResult).ToLower()));

                // Add PerCL say script to PerCL container
                script.Add(say);
            }
            else
            {
                // Create PerCL say script with US English as the language
                Say say = new Say();
                say.setLanguage(ELanguage.EnglishUS);
                // Set prompt to indicated selection error
                say.setText("There was an error in selecting a color.");

                // Add PerCL say script to PerCL container
                script.Add(say);
            }

            // Create PerCL pause script with a duration of 100 milliseconds
            Pause pause = new Pause(100);

            // Add PerCL pause script to PerCL container
            script.Add(pause);

            // Create PerCL say script with US English as the language
            Say sayGoodbye = new Say();

            sayGoodbye.setLanguage(ELanguage.EnglishUS);
            // Set prompt
            sayGoodbye.setText("Goodbye");
            // Add PerCL say script to PerCL container
            script.Add(sayGoodbye);

            // Create PerCL hangup script
            Hangup hangup = new Hangup();

            // Add PerCL hangup script to PerCL container
            script.Add(new Hangup());

            // Convert PerCL container to JSON and append to response
            return(Content(script.toJson(), "application/json"));
        }