Mixspace Lexicon logo Mixspace Lexicon

Watson Speech to Text can recognize keywords in speech input. Specifying keywords ahead of time should provide better matches than simply searching the transcript for the given words. One possible use of this feature is to add new words to the lexicon at runtime, since we cannot create new entities at runtime.

To add keywords, simply add string values to the Keywords list on the LexiconRuntime. You can add these in the Inspector or at runtime. If you change the keyword list at runtime be sure to call the LexiconRuntime Restart() method for the changes to take effect.

Use the KeywordConfidenceThreshold setting to alter the confidence level required for a keyword match. If your keywords aren’t being recognized, try setting this to a lower value.

Note that keywords are only returned with the final speech to text transcript, not with each intermediate result.

To handle keyword results, create an instance of the KeywordDetectedHandler delegate and add it to the OnKeywordDetected event:

void OnEnable()
{
    LexiconRuntime.OnKeywordDetected += OnKeywordDetected;
}

void OnDisable()
{
    LexiconRuntime.OnKeywordDetected -= OnKeywordDetected;
}

void OnKeywordDetected(LexiconSpeechResult.KeywordResult keywordResult)
{
    Debug.Log("Found Keyword: " + keywordResult.Keyword);
}