SpObjectTokenCategory GetDataKey Method

Microsoft Speech SDK

Intelligent Interface Technologies Home Page Microsoft Speech SDK

Speech Automation 5.1

Object: SpObjectTokenCategory
Type: Hidden

GetDataKey Method


The GetDataKey method returns the data key of the SpObjectTokenCategory object.

A data key object provides read and write access to the contents of a particular folder in the Speech configuration database. The data key of an SpObjectTokenCategory object accesses the folder referenced by its Id property.


SpObjectTokenCategory.GetDataKey(
     [Location As SpeechDataKeyLocation = SDKLDefaultLocation]
) As ISpeechDataKey

Parameters

Location
[Optional] Specifies the location in the speech configuration database. Default value is SDKLDefaultLocation.

Return Value

An ISpeechDataKey object.


Example

The following Visual Basic form code demonstrates the use of the GetDataKey method to enumerate the list of voices in the voices category. To run this code, create a form with the following controls:

  • A list box called List1
  • A command button called Command1
  • Paste this code into the Declarations section of the form.

    The Command1 procedure creates a new SpObjectTokenCategory object, and uses the SetId method to associate the object with the category of voices. It retrieves the data key of the category, and then the data key of the category's Tokens subfolder. It then uses the data key object's EnumKeys method to enumerate the tokens in the Tokens subfolder. The result displayed will be identical to the lists of voices displayed by the code sample in the EnumerateTokens method.


    Option Explicit
    
    Dim C As SpeechLib.SpObjectTokenCategory    'a category of object tokens
    Dim K As SpeechLib.ISpeechDataKey           'data key object
    Dim E As String                             'gets names of subkeys
    Dim ii As Integer
    
    Private Sub Command1_Click()
    
        List1.Clear
        List1.AddItem "Enumerate voice tokens with SpObjectTokenCategory.GetDataKey"
        List1.AddItem ""
    
        Set C = New SpObjectTokenCategory   'create new token category object
        C.SetId SpeechCategoryVoices        'init with ID of voices category
        
        Set K = C.GetDataKey                'set to key of voice category object
        Set K = K.OpenKey("Tokens")         'reset to key of its "Tokens" subfolder
        
        On Error Resume Next
        For ii = 0 To 9999                  'enumerate subkeys within "Tokens" subkey
            E = K.EnumKeys(ii)              'next subkey
            If Err.Number Then Exit For     'this will be used!
            List1.AddItem "   " & E
        Next
        Err.Clear
        
    End Sub