Ejemplo n.º 1
0
    /// <summary>
    /// Starts recording the user's voice via microphone and then feeds the audio data
    /// to the Speech Recognition service.
    /// Triggered from btnStartMicrophone UI Canvas button.
    /// </summary>
    public void StartSpeechRecognitionFromMicrophone()
    {
        try
        {
            if (isAuthenticated)
            {
                Debug.Log($"Creating Speech Recognition job from microphone.");
                Task <bool> recojob = recoServiceClient.CreateSpeechRecognitionJobFromVoice(auth.GetAccessToken(), region, samplingResolution, numChannels, samplingRate);

                StartCoroutine(WaitUntilRecoServiceIsReady());
            }
            else
            {
                string msg = "Cannot start speech recognition job since authentication has not successfully completed.";
                Debug.Log(msg);
                UpdateUICanvasLabel(msg, FontStyle.Normal);
            }
        }
        catch (Exception ex)
        {
            string msg = String.Format("Error: Something went wrong when starting the recognition process from the microphone. See error details below:{0}{1}{2}{3}",
                                       Environment.NewLine, ex.ToString(), Environment.NewLine, ex.Message);
            Debug.LogError(msg);
            UpdateUICanvasLabel(msg, FontStyle.Normal);
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Starts recording the user's voice via microphone and then feeds the audio data
    /// to the Speech Recognition service.
    /// Triggered from btnStartMicrophone UI Canvas button.
    /// </summary>
    public void StartSpeechRecognitionFromMicrophone()
    {
        Debug.Log($"Creating Speech Recognition job from microphone.");

        Task <bool> recojob = recoServiceClient.CreateSpeechRecognitionJobFromVoice(auth.GetAccessToken(), region, samplingResolution, numChannels, samplingRate);

        StartCoroutine(WaitUntilRecoServiceIsReady());
    }