Creating synthesizer resources

After initializing the Universal Speech Access API, applications use USAI functions to request text-to-speech (TTS) synthesizer resources from a speech server. Each synthesizer resource is associated with a specific NaturalAccess context.

Applications invoke saiCreateSynthesizer to allocate synthesizer resources. When using saiCreateSynthesizer, the application must specify the following:

saiCreateSynthesizer is an asynchronous function. When saiCreateSynthesizer executes successfully, indicating that all specified parameters are valid, USAI sends a setup command to the speech server requesting a new synthesizer resource according to the specified parameters. USAI returns a synthesizer handle (synthHd) that the application references in subsequent requests for that resource. However, the application must wait for USAI to return SAIEVN_ENGINE_READY for the specified synthesizer before making any requests with the returned synthHd.

Note: After an application invokes saiCreateSynthesizer, the only command that USAI can execute before receiving SAIEVN_ENGINE_READY is saiReleaseSynthesizer.

The following illustration shows NaturalAccess and USAI interaction when creating synthesizer resources:

The following example shows how an application creates a USAI synthesizer resource:

DWORD rc = SUCCESS;
CTAQUEUEHD queueHd;
CTAHD contextHd;
SAI_SYNTHESIZER_HANDLE synthHd;

CTA_SERVICE_NAME cta_srvc_name;
CTA_INIT_PARMS cta_init_parms;
CTA_SERVICE_DESC cta_srvc_desc;
SAI_URL g_server = "SpeechServer";
SAI_RTP_ENDPOINT rtpEndpoint;
CTA_EVENT *event;
DWORD serverPortTts = 0;

// Initializing Natural Access environment
ctaInitialize(cta_srvc_name, cta_init_parm);
ctaCreateQueue(NULL, 0, queueHd);
ctaCreateContext(queueHd, 0, NULL, contextHd);
ctaOpenServices(contextHd, cta_srvc_desc, 1);
rtpEndPoint.Port = 2000;
rtpEndPoint.ipAddress = "10.10.1.1";

    rc = saiCreateSynthesizer(contextHd, rtpEndpoint, g_server, 0, synthHd );
    if ( rc == SUCCESS )
    {
        // Wait for SAIEVN_ENGINE_READY or SAIEVN_ENGINE_FAIL
        rc = ctaWaitEvent( queueHd, event, 0 );        
        if ( (rc == SUCCESS) && (event == SAIEVN_ENGINE_READY))
        {
            SAI_EVENT_ENGINE_READY* serverPort = (SAI_EVENT_ENGINE_READY*) (event->buffer );
            printf("Engine created successfuly, Port # :%d\n", serverPortàenginePort);
        }
            else if((rc == SUCCESS) && (event == SAIEVN_ENGINE_FAIL))
        {
            printf("Engine creation failed, engine not ready.\n");
        }
    }
    else
    {
        printf("saiCreateSynthesizer failed.\n");
    }