/// <summary> /// Sets the speech event listener. /// </summary> /// <param name="onReadyForSpeech">On ready for speech.</param> /// <param name="onBeginningOfSpeech">On beginning of speech.</param> /// <param name="onEndOfSpeech">On end of speech.</param> /// <param name="onError">On error.</param> /// <param name="onResults">On results.</param> /// <param name="onShowExtraSupportedLanguage">On show extra supported language.</param> /// <param name="onSpeechSearchComplete">On speech search complete.</param> /// <param name="onSpeechSearchFail">On speech search fail.</param> private void setSpeechEventListener( Action <string> onReadyForSpeech , Action <string> onBeginningOfSpeech , Action <string> onEndOfSpeech , Action <int> onError , Action <string> onResults , Action <string> onPartialResults , Action <string> onShowExtraSupportedLanguage , Action <string> onSpeechSearchComplete , Action <string> onSpeechSearchFail ) { #if UNITY_ANDROID if (Application.platform == RuntimePlatform.Android) { SpeechCallback speechCallback = new SpeechCallback(); speechCallback.onReadyForSpeech = onReadyForSpeech; speechCallback.onBeginningOfSpeech = onBeginningOfSpeech; speechCallback.onEndOfSpeech = onEndOfSpeech; speechCallback.onError = onError; speechCallback.onResults = onResults; speechCallback.onPartialResults = onPartialResults; speechCallback.onShowExtraSupportedLanguage = onShowExtraSupportedLanguage; speechCallback.onSpeechSearchComplete = onSpeechSearchComplete; speechCallback.onSpeechSearchFail = onSpeechSearchFail; jo.CallStatic("setSpeechEventListener", speechCallback); } else { AUP.Utils.Message(TAG, "warning: must run in actual android device"); } #endif }
public void setSpeechEventListener( Action <string> onReadyForSpeech , Action <string> onBeginningOfSpeech , Action <string> onEndOfSpeech , Action <string> onError , Action <string> onResults ) { #if UNITY_ANDROID if (Application.platform == RuntimePlatform.Android) { SpeechCallback speechCallback = new SpeechCallback(); speechCallback.onReadyForSpeech = onReadyForSpeech; speechCallback.onBeginningOfSpeech = onBeginningOfSpeech; speechCallback.onEndOfSpeech = onEndOfSpeech; speechCallback.onError = onError; speechCallback.onResults = onResults; jo.CallStatic("setSpeechEventListener", speechCallback); } else { AUP.Utils.Message(TAG, "warning: must run in actual android device"); } #endif }
public bool RemoveSpeechCallback(string keyword, SpeechCallback callback) { if (!speechCallbacks.ContainsKey(keyword)) { Debug.LogWarning("Attempting to remove callback for unregistered keyword, " + keyword + "!"); return(false); } for (int i = 0; i < speechCallbacks[keyword].Count; i++) { if (speechCallbacks[keyword][i] == callback) { speechCallbacks[keyword].RemoveAt(i); return(true); } } // callback not found for the keyword return(false); }
// If this is not called from Start(), call RegisterSpeechKeyword() from Start() to register the keyword for use before the callback is added; otherwise, // calling this function from start will register the keyword and add the callback. public bool AddSpeechCallback(string keyword, SpeechCallback callback) { if (RegisterSpeechKeyword(keyword)) { // Check to see if the callback has already been added. for (int i = 0; i < speechCallbacks[keyword].Count; i++) { if (speechCallbacks[keyword][i] == callback) { Debug.LogWarning("Attempting to add same callback for keyword"); return(false); } } speechCallbacks[keyword].Add(callback); return(true); } return(false); }
public void setSpeechEventListener( Action <string>onReadyForSpeech ,Action <string>onBeginningOfSpeech ,Action <string>onEndOfSpeech ,Action <string>onError ,Action <string>onResults ) { #if UNITY_ANDROID if(Application.platform == RuntimePlatform.Android){ SpeechCallback speechCallback = new SpeechCallback(); speechCallback.onReadyForSpeech = onReadyForSpeech; speechCallback.onBeginningOfSpeech = onBeginningOfSpeech; speechCallback.onEndOfSpeech = onEndOfSpeech; speechCallback.onError = onError; speechCallback.onResults = onResults; jo.CallStatic("setSpeechEventListener",speechCallback); }else{ AUP.Utils.Message(TAG,"warning: must run in actual android device"); } #endif }