SpObjectToken Interface (SAPI 5.4)

Speech API 5.4
Microsoft Speech API 5.4


The SpObjectToken automation object represents an available resource of a type used by SAPI. The default interface for this object is ISpeechObjectTokens.

The Speech configuration database contains folders representing the resources on a computer that are used by SAPI 5.1 or later speech recognition (SR) and text-to-speech (TTS). These folders are organized into resource categories, such as voices, lexicons, and audio input devices. The SpObjectTokenCategory object provides access to a category of resources, and the SpObjectToken object provides access to a single resource.

Several Speech Automation objects support methods that return collections of resources from a specific category of available resources. Examples are SpVoice.GetAudioOutputs, SpVoice.GetVoices and SpSharedRecognizer.GetProfiles, as well as the SpObjectToken object's MatchesAttributes method. Each of these operations returns an ISpeechObjectTokens object variable containing a collection of SpObjectToken objects.

The read-only Id property of an SpObjectToken object is the path to the folder of the resource with which it is associated. The read-only DataKey property is a data key object providing read and write access to this folder. An SpObjectToken created with the New keyword has an empty Id property, and is therefore not associated with a resource. Before it can be used, a new SpObjectToken must be associated with a resource by means of its SetId method.

The SpObjectToken object also provides the ability to create and access storage files associated with a resource. The paths of data storage files created by an engine or by applications for a specific resource are stored in its object token.

See the SpObjectToken Example for a complete example and additional details.

Automation Interface Elements

The SpObjectToken automation interface contains the following elements:

Category PropertyReturns the category of the object token as an SpObjectTokenCategory object.
DataKey PropertyReturns the data key of the object token as an ISpeechDataKey object.
Id PropertyReturns the ID of the token.
CreateInstance MethodCreates an instance of the object represented by the token.
DisplayUI MethodDisplays the specified UI.
GetAttribute MethodReturns the value of the specified attribute.
GetDescription MethodReturns the name of the resource represented by the object token.
GetStorageFileName MethodCreates a storage file for data associated with the object token.
IsUISupported MethodDetermines if the specified UI is supported.
MatchesAttributes MethodIndicates whether the token matches specified attributes.
Remove MethodRemoves the token from the speech configuration database.
RemoveStorageFileName MethodRemoves a storage file associated with the object token.
SetId MethodAssociates a new object token with a resource by setting its ID property.