{"version":3,"sources":["src/common.speech/AvatarSynthesisAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,YAAY,EAEZ,iBAAiB,EAGpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,2BAA2B,EAC3B,kBAAkB,EAElB,oBAAoB,EACpB,iBAAiB,EACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,qBAAa,sBAAuB,SAAQ,oBAAoB;IAC5D,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAoB;IAC1D,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAe;gBAG5C,cAAc,EAAE,eAAe,EAC/B,iBAAiB,EAAE,2BAA2B,EAC9C,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,YAAY;IAU9B,SAAS,CAAC,mCAAmC,IAAI,IAAI;IAIrD,SAAS,CAAC,+BAA+B,IAAI,IAAI;IA2DjD,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;CAa9D","file":"AvatarSynthesisAdapter.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n    AvatarConfig,\r\n    AvatarEventArgs,\r\n    AvatarSynthesizer,\r\n    PropertyId,\r\n    Synthesizer,\r\n} from \"../sdk/Exports.js\";\r\nimport {\r\n    ISynthesisConnectionFactory,\r\n    ISynthesisMetadata,\r\n    ISynthesisSectionVideo,\r\n    SynthesisAdapterBase,\r\n    SynthesizerConfig\r\n} from \"./Exports.js\";\r\nimport { IAuthentication } from \"./IAuthentication.js\";\r\n\r\nexport class AvatarSynthesisAdapter extends SynthesisAdapterBase {\r\n    private readonly privAvatarSynthesizer: AvatarSynthesizer;\r\n    private readonly privAvatarConfig: AvatarConfig;\r\n\r\n    public constructor(\r\n        authentication: IAuthentication,\r\n        connectionFactory: ISynthesisConnectionFactory,\r\n        synthesizerConfig: SynthesizerConfig,\r\n        avatarSynthesizer: AvatarSynthesizer,\r\n        avatarConfig: AvatarConfig,\r\n        ) {\r\n\r\n        super(authentication, connectionFactory,\r\n            synthesizerConfig, undefined);\r\n        this.privAvatarSynthesizer = avatarSynthesizer;\r\n        this.privSynthesizer = avatarSynthesizer as Synthesizer;\r\n        this.privAvatarConfig = avatarConfig;\r\n    }\r\n\r\n    protected setSynthesisContextSynthesisSection(): void {\r\n        this.privSynthesisContext.setSynthesisSection(undefined);\r\n    }\r\n\r\n    protected setSpeechConfigSynthesisSection(): void {\r\n        const talkingAvatarConfig: ISynthesisSectionVideo[\"talkingAvatar\"] = {\r\n            background: {\r\n                color: this.privAvatarConfig.backgroundColor,\r\n                image: {\r\n                    url: this.privAvatarConfig.backgroundImage?.toString(),\r\n                }\r\n            },\r\n            character: this.privAvatarConfig.character,\r\n            customized: this.privAvatarConfig.customized,\r\n            photoAvatarBaseModel: this.privAvatarConfig.photoAvatarBaseModel,\r\n            style: this.privAvatarConfig.style,\r\n            useBuiltInVoice: this.privAvatarConfig.useBuiltInVoice,\r\n        };\r\n\r\n        // Add scene configuration if provided\r\n        if (this.privAvatarConfig.scene) {\r\n            talkingAvatarConfig.scene = {\r\n                amplitude: this.privAvatarConfig.scene.amplitude,\r\n                positionX: this.privAvatarConfig.scene.positionX,\r\n                positionY: this.privAvatarConfig.scene.positionY,\r\n                rotationX: this.privAvatarConfig.scene.rotationX,\r\n                rotationY: this.privAvatarConfig.scene.rotationY,\r\n                rotationZ: this.privAvatarConfig.scene.rotationZ,\r\n                zoom: this.privAvatarConfig.scene.zoom,\r\n            };\r\n        }\r\n\r\n        this.privSynthesizerConfig.synthesisVideoSection = {\r\n            format: {\r\n                bitrate: this.privAvatarConfig.videoFormat?.bitrate,\r\n                codec: this.privAvatarConfig.videoFormat?.codec,\r\n                crop: {\r\n                    bottomRight: {\r\n                        x: this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.x,\r\n                        y: this.privAvatarConfig.videoFormat?.cropRange?.bottomRight?.y,\r\n                    },\r\n                    topLeft: {\r\n                        x: this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.x,\r\n                        y: this.privAvatarConfig.videoFormat?.cropRange?.topLeft?.y,\r\n                    },\r\n                },\r\n                resolution: {\r\n                    height: this.privAvatarConfig.videoFormat?.height,\r\n                    width: this.privAvatarConfig.videoFormat?.width,\r\n                },\r\n            },\r\n            protocol: {\r\n                name: \"WebRTC\",\r\n                webrtcConfig: {\r\n                    clientDescription: btoa(this.privSynthesizerConfig.parameters.getProperty(PropertyId.TalkingAvatarService_WebRTC_SDP)),\r\n                    iceServers: this.privAvatarConfig.remoteIceServers ?? this.privAvatarSynthesizer.iceServers,\r\n                },\r\n            },\r\n            talkingAvatar: talkingAvatarConfig,\r\n        } as ISynthesisSectionVideo;\r\n    }\r\n\r\n\r\n    protected onAvatarEvent(metadata: ISynthesisMetadata): void {\r\n        if (!!this.privAvatarSynthesizer.avatarEventReceived) {\r\n            const avatarEventArgs: AvatarEventArgs = new AvatarEventArgs(\r\n                metadata.Data.Offset,\r\n                metadata.Data.Name);\r\n            try {\r\n                this.privAvatarSynthesizer.avatarEventReceived(this.privAvatarSynthesizer, avatarEventArgs);\r\n            } catch (error) {\r\n                // Not going to let errors in the event handler\r\n                // trip things up.\r\n            }\r\n        }\r\n    }\r\n}\r\n"]}