Beispiel #1
0
        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();
            }
        }
Beispiel #2
0
        private void RefreshMicsButtonOnClickHandler()
        {
            _speechRecognition.RequestMicrophonePermission(null);

            _microphoneDevicesDropdown.ClearOptions();

            for (int i = 0; i < _speechRecognition.GetMicrophoneDevices().Length; i++)
            {
                _microphoneDevicesDropdown.options.Add(new Dropdown.OptionData(_speechRecognition.GetMicrophoneDevices()[i]));
            }

            //smart fix of dropdowns
            _microphoneDevicesDropdown.value = 1;
            _microphoneDevicesDropdown.value = 0;
        }