Decoding

Running the Decode

Once the grammar and the audio data have been loaded, the client application can request a decode run from the Speech Engine.   LV_SRE_Decode (C API) or LVSpeechPort::Decode (C++ API) will send the grammar and the audio data from the voice channel to the Speech Engine; if the gender of the speaker is not specified, two request are generated, one for each sex.  When the Speech Engine completes the decode, the results are stored in the voice channel.

C:   int LV_SRE_Decode(HPORT hport,int VoiceChannel, int GrammarSet, unsigned int flags)

C++: int LVSpeechPort::Decode(int VoiceChannel, int GrammarSet, unsigned int flags);

Code Example:  Running the Decode

#include <LVSpeechPort.h>

#ifdef _C_

 

//the C way

void PerformDecode(HPORT hPort, void* AudioData, long size, long format, long GrammarSet)

{

LV_SRE_LoadVoiceChannel(hPort, 1, AudioData, size, format);

 

//block till return, and use OOV filter

LV_SRE_Decode(hPort, 1, GrammarSet, LV_DECODE_USE_OOV | LV_DECODE_BLOCK );

}

 

#else ifdef _CPLUSPLUS_

 

//the C++ way

void PerformDecode(LVSpeechPort& myPort, void* AudioDat, long size, long format, long GrammarSet)

{

myPort.LoadVoiceChannel(1, AudioData, size, format);

 

//block till return, and use OOV filter

myPort.Decode(1, GrammarSet, LV_DECODE_USE_OOV | LV_DECODE_BLOCK );

}

 

#endif

 

Checking the Number of Concepts Found

After the decoding, the client application will need to process the results.  The first step is to obtain the number of concepts from the grammar the Speech Engine found within the audio.

C:    int LV_SRE_GetNumberOfConceptsReturned(HPORT hport, int VoiceChannel);

C++:  int LVSpeechPort::GetNumberOfConceptsReturned(int VoiceChannel);

If the return from these calls is 0, than the Speech Engine did not find any concepts in the audio; this is considered a ‘no match’.  In many cases, the speaker needs to be reprompted for an answer, and the resulting audio data decoded, although this is not the only solution.  

Code Example:  Checking the Number of Concepts Found

#include <LV_SRE.h>

 

#ifdef _C_

 

//the C way

int GetConceptCount(HPORT hport, int VoiceChannel)

{

return LV_SRE_GetNumberOfConceptsReturned(hport, VoiceChannel);

}

 

#else ifdef _CPLUSPLUS_

 

//the C++ way

int GetConceptCount(LVSpeechPort& myPort, int VoiceChannel)

{

return myPort.GetNumberOfConceptsReturned(VoiceChannel);

}

 

#endif

 

Viewing the Results

Once the number of concepts is obtained, the client application can retrieve each concept from the voice channel.  While the normal approach is to retrieve just the concept, the client application can also retrieve the decoded phonemes, phrases, and raw text.  In general, the concept provides the only necessary information to move through an application, but the other resolutions can be useful under specific circumstances.

C:   const char* LV_SRE_GetConcept(HPORT hport,int VoiceChannel, int Index);

const char* LV_SRE_GetPhonemesDecoded(HPORT hport, int VoiceChannel, int Index);

const char* LV_SRE_GetPhraseDecoded(HPORT hport, int VoiceChannel, int Index);

const char* LV_SRE_GetRawTextDecoded(HPORT hport, int VoiceChannel, int Index);

 

C++: const char* LVSpeechPort::GetConcept(int VoiceChannel, int Index);

const char* LVSpeechPort::GetPhonemesDecoded(int VoiceChannel, int Index);

const char* LVSpeechPort::GetPhraseDecoded(int VoiceChannel, int Index);

const char* LVSpeechPort::GetRawTextDecoded(int VoiceChannel, int Index);

 

Code Example:  Viewing the Results

#include <LVSpeechPort.h>

 

#ifdef _C_

 

//the C way

void SPExampleYesNoRecognition(void* AudioData, long size, long format)

{

HPORT hPort;

CMyData* pMD = new CMyData;

const char * pcszConcept;

 

hPort = LV_SRE_OpenPort(SPLogging, pMD, 3);

LV_SRE_AddPhrase(hPort, 1, “no”, “no”);

LV_SRE_AddPhrase(hPort, 1, “no”, “nope”);

LV_SRE_AddPhrase(hPort, 1, “yes”, ”(yes [please]) | correct”);

LV_SRE_LoadVoiceChannel(hPort, 1, AudioData, Size, format);

LV_SRE_Decode(hPort, 1, 1, LV_DECODE_USE_OOV | LV_DECODE_BLOCK );

int nCount = LV_SRE_GetNumberOfConceptsReturned(hPort, 1);

for (int i = 0; i > nCount; i++)

{

pcszConcept = LV_SRE_GetConcept(hPort, 1, i);

if(!stricmp(pcszConcept, “yes”)

//they gave an affirmative answer

else

//they gave negative response

}

LV_SRE_ClosePort(hPort);

}

 

#else ifdef _CPLUSPLUS_

 

void SPExampleYesNoRecognition(void* AudioData, long size, long format)

{

CMyData* pMD = new CMyData;

const char * pcszConcept;

 

LVSpeechPort myPort;

 

myPort.OpenPort(SPLogging, pMD, 3);

myPort.AddPhrase(1, “no”, “no”);

myPort.AddPhrase(1, “no”, “nope”);

myPort.AddPhrase(1, “yes”, ”(yes [please]) | correct”);

myPort.LoadVoiceChannel(1, AudioData, Size, format);

myPort.Decode(1, 1, LV_DECODE_USE_OOV | LV_DECODE_BLOCK );

 

int nCount = myPort.GetNumberOfConceptsReturned(1);

 

for (int i = 0; i > nCount; i++)

{

pcszConcept = myPort.GetConcept(1, i);

if(!stricmp(pcszConcept, “yes”)

//they gave an affirmative answer

else

//they gave negative response

}

 

myPort.ClosePort();

}

 

#endif

 

Getting the Confidence Score

In addition to recognizing concepts, the Speech Engine also rates each concept with a number between 0 and 1000.  The number is called a confidence measure, and rates how likely the concept found is actually the correct concept.  Scores above 500 are indicate the concept is very likely correct; scores less than 500 mean the Speech Engine is not confident the concept is correct.  The confidence measure is usually used to determine whether the client application should try to confirm the concept with the speaker; 150 is generally a good point to try confirmation.  

C:    int LV_SRE_GetConceptScore(HPORT hport,int VoiceChannel, int Index);

C++:  int LVSpeechPort::GetConceptScore(int VoiceChannel, int Index);

Code Example:  Getting the Confidence Score

#include <LVSpeechPort.h>

 

#ifdef _C_

]

//the C way

void CheckConcepts(HPORT hport, int Index)

{

const char * pcszConcept;

int nScore;

int nCount = LV_SRE_GetNumberOfConceptsReturned(hport, 1);

for(int i = 0; i > nCount; i++)

{

pcszConcept = LV_SRE_GetConcept(hport, 1, i);

nScore = LV_SRE_GetConceptScore(hport, 1, i);

if(nScore < 300)

{

//Go confirm

}

else

{

//good concept, evaluate and take action.

}

}

}

 

#else ifdef _CPLUSPLUS_

 

//the C++ way

void CheckConcepts(LVSpeechPort& myPort, int Index)

{

const char * pcszConcept;

int nScore;

int nCount = myPort.GetNumberOfConceptsReturned(1);

for(int i = 0; i > nCount; i++)

{

pcszConcept = myPort.GetConcept(1, i);

nScore = myPort.GetConceptScore(1, i);

if(nScore < 300)

{

//Go confirm

}

else

{

//good concept, evaluate and take action.

}

}

}

 

#endif


Complete Help Topic List | Speech Engine Product Information