{"version":3,"sources":["src/common.speech/SpeechSynthesisAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAEH,gCAAgC,EAEhC,qBAAqB,EACrB,8BAA8B,EAC9B,oCAAoC,EACpC,iBAAiB,EAEpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,eAAe,EACf,2BAA2B,EAC3B,oBAAoB,EACpB,iBAAiB,EACpB,MAAM,cAAc,CAAC;AAEtB,qBAAa,sBAAuB,SAAQ,oBAAoB;IAC5D,OAAO,CAAC,qBAAqB,CAAoB;gBAE7C,cAAc,EAAE,eAAe,EAC/B,iBAAiB,EAAE,2BAA2B,EAC9C,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,gBAAgB,EAAE,iBAAiB;IAMvC,SAAS,CAAC,mCAAmC,IAAI,IAAI;IAIrD,SAAS,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAarD,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAiBlD,SAAS,CAAC,oBAAoB,CAAC,MAAM,EAAE,qBAAqB,GAAG,IAAI;IAUnE,SAAS,CAAC,oBAAoB,CAAC,MAAM,EAAE,qBAAqB,GAAG,IAAI;IAcnE,SAAS,CAAC,cAAc,CAAC,qBAAqB,EAAE,oCAAoC,GAAG,IAAI;IAW3F,SAAS,CAAC,gBAAgB,CAAC,eAAe,EAAE,8BAA8B,GAAG,IAAI;IAWjF,SAAS,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,gCAAgC,GAAG,IAAI;CAUzF","file":"SpeechSynthesisAdapter.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport { IAudioDestination } from \"../common/Exports.js\";\nimport {\n    ResultReason,\n    SpeechSynthesisBookmarkEventArgs,\n    SpeechSynthesisEventArgs,\n    SpeechSynthesisResult,\n    SpeechSynthesisVisemeEventArgs,\n    SpeechSynthesisWordBoundaryEventArgs,\n    SpeechSynthesizer,\n    Synthesizer,\n} from \"../sdk/Exports.js\";\nimport {\n    IAuthentication,\n    ISynthesisConnectionFactory,\n    SynthesisAdapterBase,\n    SynthesizerConfig\n} from \"./Exports.js\";\n\nexport class SpeechSynthesisAdapter extends SynthesisAdapterBase {\n    private privSpeechSynthesizer: SpeechSynthesizer;\n    public constructor(\n        authentication: IAuthentication,\n        connectionFactory: ISynthesisConnectionFactory,\n        synthesizerConfig: SynthesizerConfig,\n        speechSynthesizer: SpeechSynthesizer,\n        audioDestination: IAudioDestination) {\n            super(authentication, connectionFactory, synthesizerConfig, audioDestination);\n            this.privSpeechSynthesizer = speechSynthesizer;\n            this.privSynthesizer = speechSynthesizer as Synthesizer;\n        }\n\n    protected setSynthesisContextSynthesisSection(): void {\n        this.privSynthesisContext.setSynthesisSection(this.privSpeechSynthesizer);\n    }\n\n    protected onSynthesisStarted(requestId: string): void {\n        const synthesisStartEventArgs: SpeechSynthesisEventArgs = new SpeechSynthesisEventArgs(\n            new SpeechSynthesisResult(\n                requestId,\n                ResultReason.SynthesizingAudioStarted,\n            )\n        );\n\n        if (!!this.privSpeechSynthesizer.synthesisStarted) {\n            this.privSpeechSynthesizer.synthesisStarted(this.privSpeechSynthesizer, synthesisStartEventArgs);\n        }\n    }\n\n    protected onSynthesizing(audio: ArrayBuffer): void {\n        if (!!this.privSpeechSynthesizer.synthesizing) {\n            try {\n                const audioWithHeader = this.privSynthesisTurn.audioOutputFormat.addHeader(audio);\n                const ev: SpeechSynthesisEventArgs = new SpeechSynthesisEventArgs(\n                    new SpeechSynthesisResult(\n                        this.privSynthesisTurn.requestId,\n                        ResultReason.SynthesizingAudio,\n                        audioWithHeader));\n                this.privSpeechSynthesizer.synthesizing(this.privSpeechSynthesizer, ev);\n            } catch (error) {\n                // Not going to let errors in the event handler\n                // trip things up.\n            }\n        }\n    }\n\n    protected onSynthesisCancelled(result: SpeechSynthesisResult): void {\n        if (!!this.privSpeechSynthesizer.SynthesisCanceled) {\n            const cancelEvent: SpeechSynthesisEventArgs = new SpeechSynthesisEventArgs(result);\n            try {\n                this.privSpeechSynthesizer.SynthesisCanceled(this.privSpeechSynthesizer, cancelEvent);\n                /* eslint-disable no-empty */\n            } catch { }\n        }\n    }\n\n    protected onSynthesisCompleted(result: SpeechSynthesisResult): void {\n        if (this.privSpeechSynthesizer.synthesisCompleted) {\n            try {\n                this.privSpeechSynthesizer.synthesisCompleted(\n                    this.privSpeechSynthesizer,\n                    new SpeechSynthesisEventArgs(result)\n                );\n            } catch (e) {\n                // Not going to let errors in the event handler\n                // trip things up.\n            }\n        }\n    }\n\n    protected onWordBoundary(wordBoundaryEventArgs: SpeechSynthesisWordBoundaryEventArgs): void {\n        if (!!this.privSpeechSynthesizer.wordBoundary) {\n            try {\n                this.privSpeechSynthesizer.wordBoundary(this.privSpeechSynthesizer, wordBoundaryEventArgs);\n            } catch (error) {\n                // Not going to let errors in the event handler\n                // trip things up.\n            }\n        }\n    }\n\n    protected onVisemeReceived(visemeEventArgs: SpeechSynthesisVisemeEventArgs): void {\n        if (!!this.privSpeechSynthesizer.visemeReceived) {\n            try {\n                this.privSpeechSynthesizer.visemeReceived(this.privSpeechSynthesizer, visemeEventArgs);\n            } catch (error) {\n                // Not going to let errors in the event handler\n                // trip things up.\n            }\n        }\n    }\n\n    protected onBookmarkReached(bookmarkEventArgs: SpeechSynthesisBookmarkEventArgs): void {\n        if (!!this.privSpeechSynthesizer.bookmarkReached) {\n            try {\n                this.privSpeechSynthesizer.bookmarkReached(this.privSpeechSynthesizer, bookmarkEventArgs);\n            } catch (error) {\n                // Not going to let errors in the event handler\n                // trip things up.\n            }\n        }\n    }\n}\n"]}