Assets/SpeechToText/Scripts/SpeechToTextServices/WatsonSpeechToTextComponent.cs
/// <summary>
/// Populates and returns a SpeechToTextResult object from a given Watson SpeechResult object.
/// </summary>
/// <param name="watsonResult">Watson SpeechResult object</param>
/// <returns>A SpeechToTextResult object</returns>
Populates and returns a SpeechToTextResult object from a given Watson SpeechResult object.
Populates and returns a SpeechToTextResult object from a given Watson SpeechResult object .
public SpeechToTextResult CreateSpeechToTextResult(SpeechRecognitionResult watsonResult)
        {
            var textResult = new SpeechToTextResult();
            textResult.IsFinal = watsonResult.final;
            textResult.TextAlternatives = new TextAlternative[watsonResult.alternatives.Length];
            for (int i = 0; i < textResult.TextAlternatives.Length; ++i)
            {
                SpeechRecognitionAlternative watsonAlternative = watsonResult.alternatives[i];
                var alternative = new WatsonTextAlternative();
                alternative.Text = watsonAlternative.transcript;
                alternative.Confidence = (float)watsonAlternative.confidence;
                alternative.TimeStamps = watsonAlternative.Timestamps;
                alternative.WordConfidenceValues = watsonAlternative.WordConfidence;
                textResult.TextAlternatives[i] = alternative;
            }
            return textResult;
        }
public SpeechToTextResult CreateSpeechToTextResult ( SpeechRecognitionResult watsonResult ) { var textResult = new SpeechToTextResult ( ) ; textResult . IsFinal = watsonResult . final ; textResult . TextAlternatives = new TextAlternative [ watsonResult . alternatives . Length ] ; for ( int i = 0 ; i < textResult . TextAlternatives . Length ; ++ i ) { SpeechRecognitionAlternative watsonAlternative = watsonResult . alternatives [ i ] ; var alternative = new WatsonTextAlternative ( ) ; alternative . Text = watsonAlternative . transcript ; alternative . Confidence = ( float ) watsonAlternative . confidence ; alternative . TimeStamps = watsonAlternative . Timestamps ; alternative . WordConfidenceValues = watsonAlternative . WordConfidence ; textResult . TextAlternatives [ i ] = alternative ; } return textResult ; }
Populates and returns a SpeechToTextResult object from a given Watson SpeechResult object.
Populates and returns a SpeechToTextResult object from a given Watson SpeechResult object .
A SpeechToTextResult object
A SpeechToTextResult object
watsonResult
SpeechRecognitionResult
Watson SpeechResult object
Watson SpeechResult object