예제 #1
0
    public void StartBoundingBox()
    {
        var             voiceManager    = GameObject.FindGameObjectWithTag("VoiceManager");
        VoiceRecorder   voiceRecorder   = voiceManager.GetComponent <VoiceRecorder>();
        AudioRecognizer audioRecognizer = voiceManager.GetComponent <AudioRecognizer>();
        var             eventTrigger    = this.gameObject.AddComponent <ObservableEventTrigger>();

        eventTrigger.OnPointerEnterAsObservable().Subscribe(_ => {
            Image img = this.GetComponent <Image>();
            Color c   = img.color;
            c.a       = 0.5f;
            img.color = c;
        });
        eventTrigger.OnPointerExitAsObservable().Subscribe(_ => {
            Image img = this.GetComponent <Image>();
            Color c   = img.color;
            c.a       = 0.1f;
            img.color = c;
        });
        eventTrigger.OnPointerDownAsObservable().Subscribe(_ => {
            voiceRecorder.StartRecord();
        });
        eventTrigger.OnPointerUpAsObservable().Subscribe(_ => {
            var rec_data = voiceRecorder.FinishRecord();
            audioRecognizer.SpeechToText(rec_data);
            audioRecognizer.transcriptSubject.Subscribe(txt => {
                AddData(txt);
            });
        });
    }
예제 #2
0
    // Use this for initialization
    void Start()
    {
        VoiceRecorder   voiceRecorder   = voiceManager.GetComponent <VoiceRecorder>();
        AudioRecognizer audioRecognizer = voiceManager.GetComponent <AudioRecognizer>();

        recordButton.OnClickAsObservable().Subscribe(_ => {
            if (!isRecording)
            {
                voiceRecorder.StartRecord();
                materialButton.iconVectorImageData = stopIcon;
            }
            else
            {
                materialButton.iconVectorImageData = startIcon;
                var rec_data = voiceRecorder.FinishRecord();
                audioRecognizer.SpeechToText(rec_data);
                audioRecognizer.transcriptSubject.Subscribe(txt => {
                    inputField.text = txt;
                });
            }
            isRecording = !isRecording;
        });
        addButton.OnClickAsObservable().Subscribe(_ => {
            if (inputField.text != "")
            {
                commentController.AddComment(inputField.text);
                inputField.text = "";
            }
        });
    }
예제 #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="outputTextBlock">TextBlock control to write Detailed info into.</param>
        /// <param name="settings">Starting settings for the application.</param>
        /// <param name="UIDispatcher">CoreDispatcher used for dispatching replay of captured audio.</param>
        public MainPageViewModel(Settings settings, SettingsViewModel settingsViewModel, CoreDispatcher UIDispatcher)
        {
            Settings               = settings;
            this.UIDispatcher      = UIDispatcher;
            this.settingsViewModel = settingsViewModel;
            recognizer             = new AudioRecognizer();

            // Audio Provider on WASM is handled in javascript
#if NETFX_CORE || __ANDROID__
            audioRecorder = new AudioDataProvider();
#endif
        }