Assets/SpeechToText/Scripts/SpeechToTextWidgets/SpeechToTextServiceWidget.cs
/// <summary>
/// Function that is called when a speech-to-text result is received. If it is a final result and this widget
/// is waiting for the last result of the session, then the widget will begin processing the end results
/// of the session.
/// </summary>
/// <param name="result">The speech-to-text result</param>
Function that is called when a speech-to-text result is received. If it is a final result and this widget
is waiting for the last result of the session, then the widget will begin processing the end results
of the session.
Function that is called when a speech - to - text result is received . If it is a final result and this widget is waiting for the last result of the session then the widget will begin processing the end results of the session .
void OnTextResult(SpeechToTextResult result)
        {
            if (m_WillDisplayReceivedResults)
            {
                m_LastResultWasFinal = result.IsFinal;
                if (result.IsFinal)
                {
                    m_PreviousFinalResults += result.TextAlternatives[0].Text;
                    m_ResultsTextUI.color = m_FinalTextResultColor;
                    m_ResultsTextUI.text = m_PreviousFinalResults;
                    SmartLogger.Log(DebugFlags.SpeechToTextWidgets, m_SpeechToTextService.GetType().ToString() + " final result");
                    if (m_WaitingForLastFinalResultOfSession)
                    {
                        m_WaitingForLastFinalResultOfSession = false;
                        ProcessEndResults();
                    }
                }
                else
                {
                    m_ResultsTextUI.color = m_InterimTextResultColor;
                    m_ResultsTextUI.text = m_PreviousFinalResults + result.TextAlternatives[0].Text;
                }
            }
        }
void OnTextResult ( SpeechToTextResult result ) { if ( m_WillDisplayReceivedResults ) { m_LastResultWasFinal = result . IsFinal ; if ( result . IsFinal ) { m_PreviousFinalResults += result . TextAlternatives [ 0 ] . Text ; m_ResultsTextUI . color = m_FinalTextResultColor ; m_ResultsTextUI . text = m_PreviousFinalResults ; SmartLogger . Log ( DebugFlags . SpeechToTextWidgets , m_SpeechToTextService . GetType ( ) . ToString ( ) + " " ) ; if ( m_WaitingForLastFinalResultOfSession ) { m_WaitingForLastFinalResultOfSession = false ; ProcessEndResults ( ) ; } } else { m_ResultsTextUI . color = m_InterimTextResultColor ; m_ResultsTextUI . text = m_PreviousFinalResults + result . TextAlternatives [ 0 ] . Text ; } } }
Function that is called when a speech-to-text result is received.
Function that is called when a speech - to - text result is received .
// For the purposes of comparing results, this just uses the first alternative
result
SpeechToTextResult
The speech-to-text result
The speech - to - text result