<<>> <> <> <> <> <> DIRECTORY IO, RefID USING [ ID ], Rope USING [ROPE], RuntimeError USING [ UNCAUGHT ], SRPCCalls USING [ Conversation, Error, GetSHandle, NewRPCConversation, ReleaseConversation, ReportProc, SHandle, TimeoutEnable], SunRPC, Thrush, ThrushSunRPC, ThrushSunRPCConvert, SynthesizerServer, SynthesizerServerRpcControl, SynthesizerServerSunImport, SynthesizerServerSunRPC, SynthesizerServerSunRPCClient, VoiceUtils ; SynthesizerServerToSynthesizerServerSunRPC: CEDAR PROGRAM IMPORTS IO, RuntimeError, SRPCCalls, SynthesizerServerSunRPCClient, ThrushSunRPCConvert, VoiceUtils EXPORTS SynthesizerServerSunImport = { OPEN IO, ThrushSunRPCConvert; sunSHHH: CARD32 = 0; SHandle: TYPE ~ SRPCCalls.SHandle; <<>> InterfaceRecord: TYPE ~ SynthesizerServerRpcControl.InterfaceRecord; <> TextToSpeech: PROC [ interface: InterfaceRecord, shhh: Thrush.SHHH_Thrush.none, credentials: Thrush.Credentials, -- authenticates caller serviceID: RefID.ID, -- identifies particular service textToSpeak: Rope.ROPE, actionID: Thrush.ActionID, filter: BOOL_TRUE, queueIt: BOOL_TRUE ] RETURNS [nb: Thrush.NB] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srNB _ SynthesizerServerSunRPCClient.TextToSpeech[h: GetHandle[shhh], shhh: sunSHHH, credentials: CredentialsToSr[credentials], serviceID: serviceID, textToSpeak: ROPEToSr[textToSpeak], actionID: actionID, filter: filter, queueIt: queueIt]; nb _ SrToATOM[srNB]; }; StopSpeech: PROC [ interface: InterfaceRecord, shhh: Thrush.SHHH_Thrush.none, credentials: Thrush.Credentials, serviceID: RefID.ID, reset: BOOL _ FALSE ] RETURNS [nb: Thrush.NB] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srNB _ SynthesizerServerSunRPCClient.StopSpeech[h: GetHandle[shhh], shhh: sunSHHH, credentials: CredentialsToSr[credentials], serviceID: serviceID, reset: reset]; nb _ SrToATOM[srNB]; }; GetSynthesizerSpecifications: PROC [ interface: InterfaceRecord, shhh: Thrush.SHHH_Thrush.none, serviceID: RefID.ID ] RETURNS [ nb: Thrush.NB, synthesizerModel: ATOM, synthesizerVersion: ATOM ] = { ENABLE { SRPCCalls.Error => { nb _ ReportError[shhh, errCode, explanation]; CONTINUE; }; RuntimeError.UNCAUGHT => { nb _ ReportError[shhh, $unknownError]; CONTINUE; }; }; srNB: ThrushSunRPC.NB; srSm, srSv: Rope.ROPE; [srNB, srSm, srSv] _ SynthesizerServerSunRPCClient.GetSynthesizerSpecifications[h: GetHandle[shhh], shhh: sunSHHH, serviceID: serviceID]; nb _ SrToATOM[srNB]; synthesizerModel _ SrToATOM[srSm]; synthesizerVersion _ SrToATOM[srSv]; }; <> GetHandle: PROC[shhh: Thrush.SHHH] RETURNS [h: SunRPC.Handle] ~ { sHandle: SHandle; IF shhh = NIL THEN SRPCCalls.Error[$noConversationSupplied]; sHandle _ SRPCCalls.GetSHandle[shhh]; IF sHandle=NIL THEN SRPCCalls.Error[$invalidConversationSupplied]; h _ sHandle.handle; }; <> sunPgm: CARD _ 390911; -- decimal program number for VoiceRopeServer sunPgmVersion: CARD _ 1; sunCallTimeout: INT _ 3000; sunCallRetries: INT _ 3; sunCallTimeoutEnable: SRPCCalls.TimeoutEnable _ always; ImportInterface: PUBLIC PROC [instance: Rope.ROPE] RETURNS [interface: InterfaceRecord, shhh: Thrush.SHHH] ~ { <> shhh _ SRPCCalls.NewRPCConversation[serverName: instance, rpcProgram: sunPgm, rpcVersion: sunPgmVersion, timeoutEnable: sunCallTimeoutEnable, timeoutInMs: sunCallTimeout, retries: sunCallRetries, reportProc: ForwardReports]; SRPCCalls.GetSHandle[shhh].enabled _ TRUE; interface _ NEW[SynthesizerServerRpcControl.InterfaceRecordObject]; interface^ _ [ clientStubTextToSpeech: TextToSpeech, clientStubStopSpeech: StopSpeech, clientStubGetSynthesizerSpecifications: GetSynthesizerSpecifications ]; }; UnImportInterface: PUBLIC PROC [shhh: Thrush.SHHH] ~ { SRPCCalls.ReleaseConversation[shhh]; }; ReportError: PROC[shhh: Thrush.SHHH, errCode: ATOM, explanation: Rope.ROPE_NIL] RETURNS[nb: Thrush.NB] ~ { sHandle: SHandle _ SRPCCalls.GetSHandle[shhh]; IF sHandle=NIL THEN RETURN; ForwardReports[sHandle, errCode, explanation]; nb _ $callFailed; }; ForwardReports: SRPCCalls.ReportProc ~ { VoiceUtils.ProblemFR[remark: "Synthesizer Server Failure, code: %g, expl: %g", where: $System, a1: atom[ec], a2: rope[expl]]; }; }. <> <> <> <<>> <<>>