Stops a speech synthesis process.
DWORD saiStopSynthesizer ( SAI_SYNTHESIZER_HANDLE synthHd, SAI_REQUEST_ID *requestIdList, SAI_REQUEST_ID *requestId )
|
Argument |
Description |
|
synthHd |
Handle associated with a synthesizer resource. |
|
requestIdList |
Pointer to a table of request IDs to be stopped. The last element must be NULL. If requestIdList is set to NULL, all speak commands queued will be stopped. |
|
requestId |
Pointer to a unique identifier associated with the request. |
|
Return value |
Description |
|
SUCCESS |
|
|
SAIERR_ENGINE_NOT_READY |
Specified synthesizer engine is not ready to handle the request. |
|
SAIERR_INVALID_PARAMETER |
One of the specified arguments is invalid. |
|
Event |
Description |
|
SAIEVN_TTS_STOP_DONE |
Request was processed. The result of the request is returned in the statusCode field of the SAIEVN_TTS_STOP_DONE event buffer. |
saiStopSynthesizer stops one or more synthesizer requests associated with a synthesizer engine. Applications use requestIdList to specify a list of synthesizer requests to stop. The SAI service provides a list of the stopped request IDs in the reqList field of the SAIEVN_TTS_STOP_DONE event buffer.
saiControlSynthesizer, saiPauseSynthesizer, saiResumeSynthesizer, saiSpeakSynthesizer
//
// Stop all active synthesizing process. TTS handle is used to reach the appropriate
// synthesis engine created and started previously.
//
// This function can be modified to stop only specified speech command (IN_PROGRESS or PENDING).
// So, a reqId list containing reqId returned after a start recognizing command must be passed
// as second argument when calling saiStopSynthesizer.
//
DWORD demoTtsStop( CTAQUEUEHD queueHd, SAI_SYNTHESIZER_HANDLE ttsHd)
{
DWORD rc = SUCCESS;
int i = 0;
CTA_EVENT event;
SAI_REQUEST_ID reqId = 0;
SAI_EVENT_TTS_STOP* eventResult = NULL;
memset( &event, 0, sizeof (CTA_EVENT) );
//
// This procedure will stop all requests. reqId associated to current request is returned.
//
rc = saiStopSynthesizer( ttsHd, NULL, &reqId );
if( rc == SUCCESS )
{
//
// Verify each event received in queue as long as the appropriate one
// (in this case: SAIEVN_TTS_STOP_DONE) is received or before timeout
// is over.
//
rc = demoWaitForEvent(queueHd, &event, SAIEVN_TTS_STOP_DONE, 0 );
}
if ( rc == SUCCESS )
{
//
// The buffer pointer contains a speech access event. Cast buffer according to the
// event type.
//
eventResult = (SAI_EVENT_TTS_STOP*)(event.buffer) ;
//
// Verify that reqId and statusCode are the same as buffer memory.
//
if( (eventResult != NULL) &&
(reqId == eventResult->header.reqId) &&
(eventResult->statusCode == SAI_SC_SUCCESS) )
{
//
// Release the allocated internal memory
//
if( (event.buffer != NULL) && (event.size & CTA_INTERNAL_BUFFER) )
{
dispFreeBuffer ( event.buffer );
}
}
else
{
printf("Status Code = 0x%08x.\n", eventResult->statusCode);
rc = !SUCCESS;
}
}
if (rc == SUCCESS)
{
printf("Stop succeed. Here is the stoped request ID list.\n");
for (i=0; i != 0; i++)
{
printf("%d\n", eventResult->reqList[i]);
}
}
else
{
printf("Stop failed, error code = 0x%08x.\n");
}
return rc;
}