Это основной код, который у меня есть.Мне нужно получить сообщение об ошибке, когда фраза не распознана, чтобы я мог передать сообщение на диаграмму потока грибка и сделать ответ на этом.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Windows.Speech;
using System.Linq;
using Fungus;
public class VoiceReq : MonoBehaviour
{
// Use this for initialization
//KeywordRecognizer keyRec;
public Flowchart flowchart;
Dictionary<string, System.Action> keyWord = new Dictionary<string, System.Action>();
PhraseRecognizer keyRec;
public void Start()
{
keyWord = new Dictionary<string, System.Action>();
ConfidenceLevel confidence = ConfidenceLevel.Low;
string lvl = "low";
//flowchart.GetStringVariable("lvl");
if (lvl == "high")
{
confidence = ConfidenceLevel.Low;
}
if (lvl == "medium")
{
confidence = ConfidenceLevel.Medium;
}
if (lvl == "high")
{
confidence = ConfidenceLevel.High;
}
//Waiter greetings and other interactions//
//GreetingStart
//GS1
keyWord.Add("How are you", () =>
{
GS();
});
//GS2
keyWord.Add("How's it going", () =>
{
GS();
});
keyRec = new KeywordRecognizer(keyWord.Keys.ToArray(),confidence);
keyRec.OnPhraseRecognized += KeywordRecognizerOnPhraseRecognized;
keyRec.Start();
}
void KeywordRecognizerOnPhraseRecognized(PhraseRecognizedEventArgs args)
{
Debug.Log("Keyword on phrase Rec");
System.Action keyWordAction;
if (keyWord.TryGetValue(args.text, out keyWordAction))
{
keyWordAction.Invoke();
}
}
void CheckIfFound(PhraseRecognizedEventArgs args)
{
System.Action keyWordAction;
if (keyWord.TryGetValue(args.text, out keyWordAction))
{
keyWordAction.Invoke();
}
}
//GreetingStart
void GS()
{
Flowchart.BroadcastFungusMessage("GS");
}
}