How can I recognize speech from line in audio devices?
Last reviewed: 9/10/2008
HOW Article ID: H090821
The information in this article applies to:
- SpeechKit 5, 6
Summary
SAPI 5 supports setting the audio input line for audio sources other than the default microphone.
With SpeechKit, applications set the CNPDeviceID and the CNPLineID values when using audio sources other than the default audio source defined in the SAPI 5 speech control panel.
More Information
Microsoft SAPI 5 provides a way to set the audio object device and line ids. To do this, you need to know the device and the line index of the line associated with the device.
For example, if you want to recognize speech from an mp3 or CD player, then do the following:
- plug the audio playback device in the line in jack on your audio card;
- enumerate the ChantAudioMixers and ChantAudioMixerLines in your application to find the line that presents the audio input jack your device in plugged into;
- set the ChantSR CNPDeviceID to the ChantAudioMixerLine DeviceID property value;
- set the ChantSR CNPLineID to the ChantAudioMixerLine Source property value;
- enable your vocabularies
- start the playback on your audio device
The following example illustrates enumerating the ChantAudio objects and setting the ChantSR audio properties:
// Get the number of mixers
numberOfAudioMixers = ChantAudio.GetResourceCount(CSRAudioMixer,0,0)
for (i = 0; i < numberOfAudioMixers; i++)
{
// Get an audio mixer
ChantAudioMixer aChantAudioMixer = ChantAudio.GetChantAudioMixer(i);
// Get the number of mixer lines
int numberOfAudioMixerLines = aChantAudioMixer.GetResourceCount(ChantSpeechResource.CSRAudioMixerLine);
for (j = 0; j < numberOfAudioMixerLines; j++)
{
// Get an audio mixer line
ChantAudioMixerLine aChantAudioMixerLine = aChantAudioMixer.GetChantAudioMixerLine(j);
// Is this device we're plugged into?
if ((nChantAudioMixer.ProductName == "My Audio Source Device") && (aChantAudioMixerLine.Name == "Line In"))
{
// Yes, use this device and line
deviceID = aChantAudioMixerLine.DeviceID
lineID = aChantAudioMixerLine.Source
break;
}
}
}
// Set the device and line ids for the recognizer
ChantSR.SetNumberProperty(CNPDeviceID, deviceID)
ChantSR.SetNumberProperty(CNPLineID, lineID)