// Use this for initialization void Start() { // communication module initialize if (gameObject.GetComponent("TCPIPConnenction") != null) { tcpConn = gameObject.GetComponent <TCPIPConnenction>(); tcpConn.New_Receive_Message_Event += Receive_New_Massage_From_TCPIP_Handler; tcpConn.Socket_Connected_Event += TcpConn_Socket_Connected_Event; tcpConn.Socket_Disconnected_Event += TcpConn_Socket_Disconnected_Event; tcpConn.Socket_Fail_Event += TcpConn_Socket_Fail_Event; TCPIP_module_ready = true; } if (bluetoothComm != null) { Bluetooth_module_ready = true; } // get speech recongnition script _speechRecognition = FrostweepGames.Plugins.GoogleCloud.SpeechRecognition.GCSpeechRecognition.Instance; // get event _speechRecognition.RecognitionSuccessEvent += newWordsRecongize; if (Comm_Method != null) { Comm_Method.ClearOptions(); Comm_Method.options.Add(new Dropdown.OptionData("TCP/IP")); Comm_Method.options.Add(new Dropdown.OptionData("Bluetooth")); Comm_Method.onValueChanged.AddListener(Comm_Method_Changed); Comm_Method.value = 1; Comm_Method.value = 0; // set defualt as TCPIP } }
private void Awake() { if (_Instance != null) { Destroy(gameObject); return; } if (isDontDestroyOnLoad) { DontDestroyOnLoad(gameObject); } _Instance = this; _serviceLocator = new ServiceLocator(); _serviceLocator.InitServices(); _mediaManager = _serviceLocator.Get <IMediaManager>(); _speechRecognitionManager = _serviceLocator.Get <ISpeechRecognitionManager>(); _mediaManager.StartedRecordEvent += StartedRecordEventHandler; _mediaManager.FinishedRecordEvent += FinishedRecordEventHandler; _mediaManager.RecordFailedEvent += RecordFailedEventHandler; _mediaManager.BeginTalkigEvent += BeginTalkigEventHandler; _mediaManager.EndTalkigEvent += EndTalkigEventHandler; _speechRecognitionManager.SetConfig(configs[currentConfigIndex]); _speechRecognitionManager.RecognitionSuccessEvent += RecognitionSuccessEventHandler; _speechRecognitionManager.NetworkRequestFailedEvent += RecognitionFailedEventHandler; _speechRecognitionManager.LongRecognitionSuccessEvent += LongRecognitionSuccessEventHandler; _speechRecognitionManager.GetOperationDataSuccessEvent += GetOperationDataSuccessEventHandler; }
private void Start() { _speechRecognition = GCSpeechRecognition.Instance; _speechRecognition.RecognizeSuccessEvent += RecognizeSuccessEventHandler; _speechRecognition.RecognizeFailedEvent += RecognizeFailedEventHandler; _speechRecognition.FinishedRecordEvent += FinishedRecordEventHandler; _speechRecognition.StartedRecordEvent += StartedRecordEventHandler; _speechRecognition.RecordFailedEvent += RecordFailedEventHandler; _speechRecognition.EndTalkigEvent += EndTalkigEventHandler; _speechRecognition.RequestMicrophonePermission(null); // select first microphone device if (_speechRecognition.HasConnectedMicrophoneDevices()) { _speechRecognition.SetMicrophoneDevice(_speechRecognition.GetMicrophoneDevices()[0]); } Debug.Log("Using microphone: " + _speechRecognition.GetMicrophoneDevices()[0].ToString()); // Ask for mic permission if (!Debug.isDebugBuild) { StartRecording(false); StopRecording(); } }
private void OnDestroy() { if (!_IsCurrentInstance) { return; } _mediaManager.RecordStartedEvent -= RecordStartedEventHandler; _mediaManager.RecordEndedEvent -= RecordEndedEventHandler; _mediaManager.RecordFailedEvent -= RecordFailedEventHandler; _mediaManager.TalkBeganEvent -= TalkBeganEventHandler; _mediaManager.TalkEndedEvent -= TalkEndedEventHandler; _speechRecognitionManager.RecognizeSuccessEvent -= RecognizeSuccessEventHandler; _speechRecognitionManager.RecognizeFailedEvent -= RecognizeFailedEventHandler; _speechRecognitionManager.LongRunningRecognizeSuccessEvent -= LongRunningRecognizeSuccessEventHandler; _speechRecognitionManager.LongRunningRecognizeFailedEvent -= LongRunningRecognizeFailedEventHandler; _speechRecognitionManager.GetOperationSuccessEvent -= GetOperationSuccessEventHandler; _speechRecognitionManager.GetOperationFailedEvent -= GetOperationFailedEventHandler; _speechRecognitionManager.ListOperationsSuccessEvent -= ListOperationsSuccessEventHandler; _speechRecognitionManager.ListOperationsFailedEvent -= ListOperationsFailedEventHandler; ServiceLocator.Instance.Dispose(); _Instance = null; }
public void Init() { _gcSpeechRecognition = GCSpeechRecognition.Instance; _networkingService = new NetworkingService(); _networkingService.NetworkResponseEvent += NetworkResponseEventHandler; CurrentConfig = Resources.Load <Config>("GCSpeechRecognitonConfig"); }
public void Init() { _gcSpeechRecognition = GCSpeechRecognition.Instance; OperationNames = new Dictionary <OperationLongRecognizeResponse, Enumerators.NetworkRequestStatus>(); _networking = new Networking(); _networking.NetworkResponseEvent += NetworkResponseEventHandler; }
/* List<string> m_DropOptions = new List<string> { * "en_AU", * "en_CA", * "en_GH", * "en_GB", * "en_IN", * "en_IE", * "en_KE", * "en_NZ", * "en_NG", * "en_PH", * "en_ZA", * "en_TZ", * "en_US" }; * * List<string> m_speechContext = new List<string> { * "weather", * "tomorrow", * "today", * "summer", * "next day", * "autumn", * "spring"}; */ // Start is called before the first frame update void Start() { //make the cube fully transparent ARObject.GetComponent <Renderer>().material.color = new Color(0.0f, 0.0f, 0.8f, 0.3f); _speechRecognition = GCSpeechRecognition.Instance; _speechRecognition.RecognizeSuccessEvent += RecognizeSuccessEventHandler; _speechRecognition.RecognizeFailedEvent += RecognizeFailedEventHandler; _speechRecognition.FinishedRecordEvent += FinishedRecordEventHandler; _speechRecognition.StartedRecordEvent += StartedRecordEventHandler; _speechRecognition.RecordFailedEvent += RecordFailedEventHandler; _speechRecognition.BeginTalkigEvent += BeginTalkigEventHandler; _speechRecognition.EndTalkigEvent += EndTalkigEventHandler; //_contextPhrasesInputField = transform.Find("Canvas/InputField_SpeechContext").GetComponent<InputField>(); _startRecordButton = transform.Find("Canvas/Button_StartRecord").GetComponent <Button>(); _closeInstructions = transform.Find("Canvas/Panel_HelpText/Button_close").GetComponent <Button>(); _helpButton = transform.Find("Canvas/NameBoard_Panel/Button_help").GetComponent <Button>(); _resultText = transform.Find("Canvas/PanelTest/GameObject/Texttest").GetComponent <Text>(); // _textTest = transform.Find("Canvas/PanelTest/GameObject/Texttest").GetComponent<Text>(); // _languageDropdown = transform.Find("Canvas/Dropdown_Language").GetComponent<Dropdown>(); _microphoneDevicesDropdown = transform.Find("Canvas/Dropdown_MicrophoneDevices").GetComponent <Dropdown>(); _voiceLevelImage = transform.Find("Canvas/Panel_VoiceLevel/Image_Level").GetComponent <Image>(); _startRecordButton.onClick.AddListener(StartRecordButtonOnClickHandler); _startRecordButton.interactable = true; _closeInstructions.onClick.AddListener(CloseInstructionPanelOnClickHandler); _helpButton.onClick.AddListener(OpenHelpPanelOnClickHandler); _microphoneDevicesDropdown.onValueChanged.AddListener(MicrophoneDevicesDropdownOnValueChangedEventHandler); //Loading the language options //_languageDropdown.ClearOptions(); //_languageDropdown.AddOptions(m_DropOptions); /* for (int i = 0; i < Enum.GetNames(typeof(Enumerators.LanguageCode)).Length; i++) * { * _languageDropdown.options.Add(new Dropdown.OptionData(((Enumerators.LanguageCode)i).Parse())); * } */ // _languageDropdown.value = _languageDropdown.options.IndexOf(_languageDropdown.options.Find(x => x.text == Enumerators.LanguageCode.en_US.Parse())); RefreshMicsButtonOnClickHandler(); //StartRecordButtonOnClickHandler(); }
private void Awake() { if (_Instance != null) { Destroy(gameObject); return; } if (isDontDestroyOnLoad) { DontDestroyOnLoad(gameObject); } _Instance = this; if (configs.Count == 0) { throw new MissingFieldException("NO CONFIG FOUND!"); } ServiceLocator.Register <ISpeechRecognitionManager>(new SpeechRecognitionManager()); ServiceLocator.Register <IVoiceDetectionManager>(new VoiceDetectionManager()); ServiceLocator.Register <IMediaManager>(new MediaManager()); ServiceLocator.InitServices(); _mediaManager = ServiceLocator.Get <IMediaManager>(); _speechRecognitionManager = ServiceLocator.Get <ISpeechRecognitionManager>(); _voiceDetectionManager = ServiceLocator.Get <IVoiceDetectionManager>(); _mediaManager.RecordStartedEvent += RecordStartedEventHandler; _mediaManager.RecordEndedEvent += RecordEndedEventHandler; _mediaManager.RecordFailedEvent += RecordFailedEventHandler; _mediaManager.TalkBeganEvent += TalkBeganEventHandler; _mediaManager.TalkEndedEvent += TalkEndedEventHandler; _speechRecognitionManager.RecognizeSuccessEvent += RecognizeSuccessEventHandler; _speechRecognitionManager.RecognizeFailedEvent += RecognizeFailedEventHandler; _speechRecognitionManager.LongRunningRecognizeSuccessEvent += LongRunningRecognizeSuccessEventHandler; _speechRecognitionManager.LongRunningRecognizeFailedEvent += LongRunningRecognizeFailedEventHandler; _speechRecognitionManager.GetOperationSuccessEvent += GetOperationSuccessEventHandler; _speechRecognitionManager.GetOperationFailedEvent += GetOperationFailedEventHandler; _speechRecognitionManager.ListOperationsSuccessEvent += ListOperationsSuccessEventHandler; _speechRecognitionManager.ListOperationsFailedEvent += ListOperationsFailedEventHandler; _speechRecognitionManager.SetConfig(configs[Mathf.Clamp(currentConfigIndex, 0, configs.Count - 1)]); }
private void OnDestroy() { if (_Instance == this) { _mediaManager.StartedRecordEvent -= StartedRecordEventHandler; _mediaManager.FinishedRecordEvent -= FinishedRecordEventHandler; _mediaManager.RecordFailedEvent -= RecordFailedEventHandler; _mediaManager.BeginTalkigEvent -= BeginTalkigEventHandler; _mediaManager.EndTalkigEvent -= EndTalkigEventHandler; _speechRecognitionManager.RecognitionSuccessEvent -= RecognitionSuccessEventHandler; _speechRecognitionManager.RecognitionFailedEvent -= RecognitionFailedEventHandler; _Instance = null; _serviceLocator.Dispose(); } }
private void Start() { _speechRecognition = GCSpeechRecognition.Instance; _speechRecognition.RecognitionSuccessEvent += SpeechRecognizedSuccessEventHandler; _speechRecognition.RecognitionFailedEvent += SpeechRecognizedFailedEventHandler; recordButton = transform.Find("Canvas_Main/Button_StartRecord").GetComponent <Button>(); runtimeButton = transform.Find("Canvas_Main/Button_AutoDetect").GetComponent <Button>(); _speechRecognitionState = transform.Find("Canvas_Main/Image_RecordState").GetComponent <Image>(); _speechRecognitionResult = transform.Find("Canvas_Main/Text_Result").GetComponent <Text>(); _languageDropdown = transform.Find("Canvas_Setting/Dropdown_Language").GetComponent <Dropdown>(); _speechRecognitionState.color = Color.white; _languageDropdown.ClearOptions(); for (int i = 0; i < Enum.GetNames(typeof(Enumerators.LanguageCode)).Length; i++) { _languageDropdown.options.Add(new Dropdown.OptionData(((Enumerators.LanguageCode)i).ToString())); } _languageDropdown.onValueChanged.AddListener(LanguageDropdownOnValueChanged); _languageDropdown.value = 40; // simple chinese, not woring currenttly if (keywords_analysis == null) { _speechRecognitionResult.text = "\nSpeech key words analysis module not assign, can not recongise any command!!\n"; } else { keywords_analysis.New_Response_Event += Response_Handle; keywords_analysis.State_Num_Change_Event += State_Num_Change_Handle; } if (AUP_Worker == null) { _speechRecognitionResult.text += "\nTTS module not assign!!\n"; } }