private void OnBotResponse(object sender, Assets.BotDirectLine.BotResponseEventArgs e) { Debug.Log($"OnBotResponse: {e.ToString()}"); switch (e.EventType) { case EventTypes.ConversationStarted: if (!string.IsNullOrWhiteSpace(e.ConversationId)) { // Store the ID textToSpeech.SpeakSsml("<?xml version=\"1.0\"?><speak speed=\"80%\" version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd\" xml:lang=\"en-US\">Bot connection established!</speak>"); conversationId = e.ConversationId; } else { textToSpeech.SpeakSsml("<?xml version=\"1.0\"?><speak speed=\"80%\" version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd\" xml:lang=\"en-US\">Error while connecting to Bot!</speak>"); } break; case EventTypes.MessageSent: if (!string.IsNullOrEmpty(conversationId)) { // Get the bot's response(s) BotDirectLineManager.Instance.GetMessagesAsync(conversationId).Wait(); } break; case EventTypes.MessageReceived: // Handle the received message(s) if (!string.IsNullOrWhiteSpace(conversationId)) { var messageActivity = e.Messages.LastOrDefault(); Debug.Log(messageActivity.Text); textToSpeech.SpeakSsml("<?xml version=\"1.0\"?><speak speed=\"80%\" version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd\" xml:lang=\"en-US\"> " + messageActivity.Text + "</speak>"); dictationRecognizer.Stop(); dictationRecognizer.DictationResult -= DictationRecognizer_DictationResult; dictationRecognizer.DictationHypothesis -= DictationRecognizer_DictationHypothesis; dictationRecognizer.DictationComplete -= DictationRecognizer_DictationComplete; dictationRecognizer.DictationError -= DictationRecognizer_DictationError; dictationRecognizer.Dispose(); //do //{ //} while (dictationRecognizer.Status != SpeechSystemStatus.Stopped); PhraseRecognitionSystem.Restart(); } break; case EventTypes.Error: // Handle the error break; } }
private void DictationRecognizer_DictationResult(string text, ConfidenceLevel confidence) { Debug.Log($"DictationRecognizer_DictationResult: {text}confidence: {confidence.ToString()}"); if (confidence == ConfidenceLevel.Rejected || confidence == ConfidenceLevel.Low) { textToSpeech.SpeakSsml("<?xml version=\"1.0\"?><speak speed=\"80%\" version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.w3.org/2001/10/synthesis http://www.w3.org/TR/speech-synthesis/synthesis.xsd\" xml:lang=\"en-US\">Sorry, but I don't understand you.</speak>"); } if (!string.IsNullOrWhiteSpace(conversationId)) { BotDirectLineManager.Instance.SendMessageAsync(conversationId, "AzureBootCamp2018", text).Wait(); } }
public void Say(string text) { Debug.Log("Ich will was sagen"); tts.SpeakSsml("<speak>" + text + "</speak>"); mesh.text = text; }