Search code examples
speech-recognitionsapi

SAPI Speech Recognition - How to create and delete recognition profiles using SpeechLib


SAPI documentation cover the creation and deletion of a recognition profile. But how can I do it with SpeechLib? I would like to:

  1. Find the currently active profile, and keep a note of it.
  2. Create a new profile.
  3. Make the new profile the active one.

When exiting my app:

  1. Delete the profile that I have created.
  2. Set back the active profile to what it was before launching my app.

BTW: Is SpeechLib documented?


Solution

  • SpeechLib documentation is found by looking for SAPI Automation interfaces.

    Profiles are a type of SpObjectToken, and can be enumerated using the SpObjectTokenCategory object. Specifically, create a new SpObjectToken, and set the ID, then use EnumerateTokens to get the profiles. (This example uses VB, but you should be able to translate)

    Dim E As SpeechLib.ISpeechObjectTokens      'an enumeration of object tokens
    Dim C As SpeechLib.SpObjectTokenCategory    'a category of object tokens    
    Set C = New SpObjectTokenCategory
    C.SetId SpeechCategoryRecoProfiles
    List1.AddItem "   " & C.Id
    Set E = C.EnumerateTokens()
    
    For Each T In E
        List1.AddItem "   " & T.GetDescription
    Next