Assets/SpeechToText/Scripts/SpeechToTextWidgets/SpeechToTextServiceWidget.cs
/// <summary>
/// Computes the accuracy (percentage) of the end text results in comparison to the given phrase, by using 
/// the Levenshtein Distance between the two strings, and displays this percentage in the results text UI.
/// </summary>
/// <param name="originalPhrase">The phrase to compare against</param>
Computes the accuracy (percentage) of the end text results in comparison to the given phrase, by using
the Levenshtein Distance between the two strings, and displays this percentage in the results text UI.
Computes the accuracy ( percentage ) of the end text results in comparison to the given phrase by using the Levenshtein Distance between the two strings and displays this percentage in the results text UI .
void DisplayAccuracyOfEndResults(string originalPhrase)
        {
            string speechToTextResult = StringUtilities.TrimSpecialFormatting(m_ResultsTextUI.text, new HashSet<char>(),
                m_LeadingCharsForSpecialWords, m_SurroundingCharsForSpecialText);
            originalPhrase = StringUtilities.TrimSpecialFormatting(originalPhrase, new HashSet<char>(),
                m_LeadingCharsForSpecialWords, m_SurroundingCharsForSpecialText);
            int levenDistance = StringUtilities.LevenshteinDistance(speechToTextResult, originalPhrase);
            SmartLogger.Log(DebugFlags.SpeechToTextWidgets, m_SpeechToTextService.GetType().ToString() + " compute accuracy of text: \"" + speechToTextResult + "\"");
            float accuracy = Mathf.Max(0, 100f - (100f * (float)levenDistance / (float)originalPhrase.Length));
            m_PreviousFinalResults = "[Accuracy: " + accuracy + "%] " + m_PreviousFinalResults;
            m_ResultsTextUI.text = m_PreviousFinalResults;
        }
void DisplayAccuracyOfEndResults ( string originalPhrase ) { string speechToTextResult = StringUtilities . TrimSpecialFormatting ( m_ResultsTextUI . text , new HashSet < char > ( ) , m_LeadingCharsForSpecialWords , m_SurroundingCharsForSpecialText ) ; originalPhrase = StringUtilities . TrimSpecialFormatting ( originalPhrase , new HashSet < char > ( ) , m_LeadingCharsForSpecialWords , m_SurroundingCharsForSpecialText ) ; int levenDistance = StringUtilities . LevenshteinDistance ( speechToTextResult , originalPhrase ) ; SmartLogger . Log ( DebugFlags . SpeechToTextWidgets , m_SpeechToTextService . GetType ( ) . ToString ( ) + " \" " + speechToTextResult + " \" " ) ; float accuracy = Mathf . Max ( 0 , 100f - ( 100f * ( float ) levenDistance / ( float ) originalPhrase . Length ) ) ; m_PreviousFinalResults = " " + accuracy + " " + m_PreviousFinalResults ; m_ResultsTextUI . text = m_PreviousFinalResults ; }
Computes the accuracy (percentage) of the end text results in comparison to the given phrase, by using
the Levenshtein Distance between the two strings, and displays this percentage in the results text UI.
Computes the accuracy ( percentage ) of the end text results in comparison to the given phrase by using the Levenshtein Distance between the two strings and displays this percentage in the results text UI .
originalPhrase
string
The phrase to compare against
The phrase to compare against