CHMlib Logo Leading Translation Management System for Translation Agencies, Top Translation Management Software for Freelance Translators, Time Tracking Software, Word Count, Character Count and Line Count Software, Computer Assisted Translation Tool for Easy Word Count, Clipboard Character Count Software, User-Friendly Translation Memory Software, Terminology Management Software, Terminology Management Server, Microsoft Glossary Software, Dictionary of Acronyms, Social Network for Translators and Translation Agencies, Acronyms and Abbreviations Search Engine, Russian Translation Lab, Ukrainian Translation Lab.
You are reading help file online using chmlib.com
CrisisHelper - First Aid in Tough Times of World Economic Crisis


Intelligent Interface Technologies Home Page Microsoft Speech SDK

Speech Automation 5.1

SpObjectToken Example

The following code example demonstrates the use of the Count property and the Item method. The sample displays all available recognizers on the computer. The available audio input devices (sound cards) or profiles may also be displayed by remarking out the other two lines and removing the remarks from the desired line.

The example works for all objects returned as ISpeechObjectTokens. ISpeechObjectTokens is actually a collection of objects. The Count property returns the number of items in the collection. The Item method returns an individual member at the given index.

The type of the members in the collection will be different based on the creating call. In this example code, the collection is a list of recognizers.

To run this code, create a form with the following control:

  • A label called Label1
  • Paste this code into the Declarations section of the form.

    Private Sub Form_Load()
        Dim SharedRecognizer As SpSharedRecognizer
        Set SharedRecognizer = New SpSharedRecognizer
        
        Dim theResources As ISpeechObjectTokens
        Set theResources = SharedRecognizer.GetRecognizers
        'Set theResources = SharedRecognizer.GetAudioInputs
        'Set theResources = SharedRecognizer.GetProfiles
    
        Dim i As Long
        Dim recoObject As SpObjectToken
    
        Label1.Caption = ""
        For i = 0 To theResources.Count - 1
            Set recoObject = theResources.Item(i)
            Label1.Caption = Label1.Caption & recoObject.GetDescription & vbCrLf
        Next i
    End Sub
    

    Count and Item may also be used for other object collections. The following code snippet demonstrates the use of the Count property and the Item method for ISpeechLexiconWords and ISpeechLexiconWord. The collection itself is of type ISpeechLexiconWords and the individual members of are type ISpeechLexiconWord. Other collections may use Count and Item in the same manner. For instance ISpeechGrammarRules and ISpeechGrammarRule may be substituted respectively for the collection and member type.

    For the sake of brevity, CreateCollection is assumed to be a function that creates the collection, again for this example of ISpeechLexiconWords. The Count property returns the count of member items and the Item method returns a specific member of the collection.

    Dim C As ISpeechLexiconWords        'The collection
    Dim M As ISpeechLexiconWord         'An item in the collection
    
    Set C = CreateCollection            'Create the collection
    
    'Get last member of the collection in object "M"
    
    lngCount = C.Count                  'How many items
    If lngCount Then
        Set M = C.Item(lngCount - 1)    'Get the last one
    End If
    


    You are reading help file online using chmlib.com

    If you want your help file to be removed or added please send e-mail to chmlibcom@gmail.com
    Partner sites: Logo Design, Simple Anti-Crisis Accounting Software, Voice Search for Web