{"version":3,"sources":["src/common.speech/SpeechContext.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,qBAAqB,EAExB,MAAM,WAAW,CAAC;AAEnB;;;GAGG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,kBAAkB,CAAwB;gBAEtC,cAAc,EAAE,qBAAqB;IAIjD;;;;OAIG;IACI,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAIxD;;;;OAIG;IACI,gCAAgC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IA2BtD,MAAM,IAAI,MAAM;CAQ1B","file":"SpeechContext.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n    DynamicGrammarBuilder,\r\n    IDynamicGrammar,\r\n} from \"./Exports\";\r\n\r\n/**\r\n * Represents the JSON used in the speech.context message sent to the speech service.\r\n * The dynamic grammar is always refreshed from the encapsulated dynamic grammar object.\r\n */\r\nexport class SpeechContext {\r\n    private privContext: { [section: string]: any } = {};\r\n    private privDynamicGrammar: DynamicGrammarBuilder;\r\n\r\n    constructor(dynamicGrammar: DynamicGrammarBuilder) {\r\n        this.privDynamicGrammar = dynamicGrammar;\r\n    }\r\n\r\n    /**\r\n     * Adds a section to the speech.context object.\r\n     * @param sectionName Name of the section to add.\r\n     * @param value JSON serializable object that represents the value.\r\n     */\r\n    public setSection(sectionName: string, value: any): void {\r\n        this.privContext[sectionName] = value;\r\n    }\r\n\r\n    /**\r\n     * @Internal\r\n     * This is only used by pronunciation assessment config.\r\n     * Do not use externally, object returned will change without warning or notice.\r\n     */\r\n    public setPronunciationAssessmentParams(params: string): void {\r\n        if (this.privContext.phraseDetection === undefined) {\r\n            this.privContext.phraseDetection = {\r\n                enrichment: {\r\n                    pronunciationAssessment: {}\r\n                }\r\n            };\r\n        }\r\n        this.privContext.phraseDetection.enrichment.pronunciationAssessment = JSON.parse(params);\r\n        if (this.privContext.phraseOutput === undefined) {\r\n            this.privContext.phraseOutput = {\r\n                detailed: {\r\n                    options: []\r\n                },\r\n                format: {}\r\n            };\r\n        }\r\n        this.privContext.phraseOutput.format = \"Detailed\";\r\n        this.privContext.phraseOutput.detailed.options.push(\"PronunciationAssessment\");\r\n        if (this.privContext.phraseOutput.detailed.options.indexOf(\"WordTimings\") === -1) {\r\n            this.privContext.phraseOutput.detailed.options.push(\"WordTimings\");\r\n        }\r\n        if (this.privContext.phraseOutput.detailed.options.indexOf(\"SNR\") === -1) {\r\n            this.privContext.phraseOutput.detailed.options.push(\"SNR\");\r\n        }\r\n    }\r\n\r\n    public toJSON(): string {\r\n\r\n        const dgi: IDynamicGrammar = this.privDynamicGrammar.generateGrammarObject();\r\n        this.setSection(\"dgi\", dgi);\r\n\r\n        const ret: string = JSON.stringify(this.privContext);\r\n        return ret;\r\n    }\r\n}\r\n"]}