saiInitSpeakList

Initializes the speak list buffer used by saiAddSpeakItem and saiSpeakSynthesizer.

Prototype

DWORD saiInitSpeakList ( void *speakList, DWORD speakListSize )

Argument

Description

speakList

Pointer to a new speak list buffer.

speakListSize

Size of the speak list.


Return values

Return value

Description

SUCCESS

 

SAIERR_INVALID_PARAMETER

One of the specified arguments is invalid.

SAIERR_NOT_ENOUGH_MEMORY

Speak list is not big enough to be used. It should contain at least enough memory for the main list header and at least one item header from a speak list.


Details

The speakListSize value must include a header and the data size of each item to be added to the list. Use the helper macro SAI_COMPUTE_LIST_OVERHEAD(nElement, overheadSize) to calculate the total overhead size according to the number of items the list contains. The speak list must contain at least one main header and one header per entry (speak rule).

Example

//
// Start synthesis with speech located in a grammar list. TTS handle is used to reach the
// appropriate synthesis engine created previously.
// The Application waits on the event queue to receive the SAIEVN_TTS_SPEAK_ACKNOWNLEDGED and
// SAIEVN_TTS_SPEAK_DONE.
//
// A XML grammar is added to a grammar list. With saiAddSpeakRule, a name tag can be associated  
// to this grammar and used to make reference to this tool.
//
DWORD demoTtsSpeakGrammarList(  CTAQUEUEHD queueHd, SAI_SYNTHESIZER_HANDLE ttsHd )
{
    DWORD rc = SUCCESS;
    char textToSpeak[MAX_TEXT_TO_SPEAK];
    SAI_REQUEST_ID reqId = 0;
    strcpy( textToSpeak, (char *)"one one two");
    rc = saiInitSpeakList( speakRuleList, sizeof(speakRuleList) );
    if ( rc == SUCCESS )
    {
        //
        // Add a speak rule to the database.
        //
        rc = saiAddSpeakItem(speakRuleList, SAI_SPEAK_DATA_TYPE_PLAIN_TEXT, textToSpeak );
    }
    if ( rc == SUCCESS )
    {
        //
/        / Call SAI speaking function. Use grammar list created previously.
        // reqId associated to the request is returned
        //
        rc = saiSpeakSynthesizer( ttsHd, SAI_SPEAK_DATA_TYPE_DATA_LIST, speakRuleList, &reqId );
    }
    if ( rc == SUCCESS )
    {
        //
        // Verify each event received in queue as long as the appropriate one
        // (in this case: SAIEVN_TTS_SPEAK_ACKNOWNLEDGED and SAIEVN_TTS_SPEAK_DONE) are
        // received or before timeout is over. Verify that status code, completion cause and
        // reqId are the same as buffer memory.
        //
        rc = demoWaitForEventSpeakFcn(queueHd, reqId);
    }
    if (rc == SUCCESS)
    {
        printf("Speak with SAI_SPEAK_DATA_TYPE_DATA_LIST succeed!.\n");
    }
    else
    {
        printf("Speak with SAI_SPEAK_DATA_TYPE_DATA_LIST failed, error code = 0x%08X.\n", rc);
    }
    return rc;
}