Распознавание речи Twilio не может записать результат речи в C#

Я пытаюсь написать приложение с программируемым голосом Twilio, чтобы иметь возможность собирать как речь, так и цифры от клиента. мой код получает цифры, но не отвечает на речевой результат. Кстати, в последней версии Twilio параметр input для команды collect не позволяет помещать строку "dmfs speech", чтобы использовать обе опции вместе, поскольку он принимает только список [InputEnums] с Dtmf и Speech by определение. Вот пример моего кода, если кто-то может помочь мне понять, что я делаю неправильно:

 public List<InputEnum> inputEnum = new List<InputEnum>() {InputEnum.Speech , InputEnum.Dtmf};  // creating a list with Dtmf and Speech options 

    var gather = new Gather(input: inputEnum, action: new Uri(baseUri,"IVR/MainMenu"), hints: "returning customer , agent", timeout: 4, numDigits: 1);

   gather.Say("If you are a returning customer and would like to place your last order, say returning customer or press 1." );
   gather.Say("To speak to an agent, say agent or press 2");

  _response.Append(gather);

    return new TwiMLResult(_response.ToString());
    }


 [HttpPost]
    public ActionResult MainMenu(string digits)
    {

        if ((digits == "1") || ( digits == "returning customer"))
        {                 
            _response.Say("Please hold while we pull up your information.");
            _response.Pause(6);

            var gather = new Gather(input: inputEnum, hints: "last order, place last order , agent", timeout: 4, action: new Uri(baseUri, "IVR/ReturnInstructions"), numDigits: 1);
            gather.Say("If you would like us to read your last order to you, say last order or press 1");
            gather.Say("To place your last order, say place last order or press 2");
            gather.Say("To speak to an agent, say agent or press 0");
            _response.Append(gather);

            return new TwiMLResult(_response.ToString());

        }

1 ответ

Я попробовал разные подходы, и оказалось, что мне нужно передать другой параметр специально для речевого результата в мое действие, и обязательно преобразовать его в нижний регистр, иначе он всегда вернет false для сравнения строк. Вот образец моего MainMenu ActionResult:

public ActionResult MainMenu(string digits = null, string speechresult = null)
    {
        if ((digits == "1") || (speechresult != null && speechresult.ToLower() == "returning customer"))
        {
            _response.Say("Please hold while we pull up your information.");
            _response.Pause(6);
            gather.Say("If you would like us to read your last order to you, say last order or press 1");
           return new TwiMLResult(_response.ToString()); 
        }
        else if ((digits == "0") || (speechresult != null && speechresult.ToLower() == "agent"))
        {
            return connectToAnAgent();
        }

        return connectToAnAgent();
    }
Другие вопросы по тегам