public static VoiceSynthesizer Instance() { if (mInstance == null) { mInstance = new VoiceSynthesizer(); } return(mInstance); }
private void StartDialog() { var currentNode = mDialogNodes.DialogNodes.First(x => x.Id == 1); var didNotUnderstand = false; var didNotUnderstandText = "I'm sorry I did not understand. Could you repeat that again?"; while (!currentNode.IsEndNode) { // When node should only be executed once, jump to alternate node if (currentNode.AskOnce && mHandledNodes.Contains(currentNode.Id)) { currentNode = mDialogNodes.DialogNodes.First(x => x.Id == currentNode.AlternateNode); continue; } // Add current node to already handled nodes if (!mHandledNodes.Contains(currentNode.Id)) { mHandledNodes.Add(currentNode.Id); } if (!didNotUnderstand) { VoiceSynthesizer.Instance().Speak(currentNode.SpeechText); } else { VoiceSynthesizer.Instance().Speak(didNotUnderstandText); } if (!currentNode.IsListenOnly) { Console.WriteLine("Speak for a response and finish with enter"); mVoiceTranscriptor.GetNextRecording().Wait(); Console.WriteLine(mVoiceTranscriptor.Transcription); } if (currentNode.PostSpeakingActions != null) { foreach (var action in currentNode.PostSpeakingActions) { mDialogActions.ExecuteAction(action); } } var nextNode = GetNextNodeFromAnswer(currentNode, mVoiceTranscriptor.Transcription); didNotUnderstand = nextNode == null; currentNode = !didNotUnderstand ? nextNode : currentNode; } VoiceSynthesizer.Instance().Speak(currentNode.SpeechText); }
public void SpeakShoppingList() { var i = 0; foreach (var item in mShoppingList) { if (i == mShoppingList.Count - 1) { VoiceSynthesizer.Instance().Speak("and"); } VoiceSynthesizer.Instance().Speak(item); i++; } }