1 |
- {"ast":null,"code":"\"use strict\";\n\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.SpeechContext = void 0;\n/**\n * Represents the JSON used in the speech.context message sent to the speech service.\n * The dynamic grammar is always refreshed from the encapsulated dynamic grammar object.\n */\nclass SpeechContext {\n constructor(dynamicGrammar) {\n this.privContext = {};\n this.privDynamicGrammar = dynamicGrammar;\n }\n /**\n * Gets a section of the speech.context object.\n * @param sectionName Name of the section to get.\n * @return string or Context JSON serializable object that represents the value.\n */\n getSection(sectionName) {\n return this.privContext[sectionName] || {};\n }\n /**\n * Adds a section to the speech.context object.\n * @param sectionName Name of the section to add.\n * @param value JSON serializable object that represents the value.\n */\n setSection(sectionName, value) {\n this.privContext[sectionName] = value;\n }\n /**\n * @Internal\n * This is only used by pronunciation assessment config.\n * Do not use externally, object returned will change without warning or notice.\n */\n setPronunciationAssessmentParams(params, contentAssessmentTopic, isSpeakerDiarizationEnabled = false) {\n if (this.privContext.phraseDetection === undefined) {\n this.privContext.phraseDetection = {\n enrichment: {\n pronunciationAssessment: {}\n }\n };\n }\n if (this.privContext.phraseDetection.enrichment === undefined) {\n this.privContext.phraseDetection.enrichment = {\n pronunciationAssessment: {}\n };\n }\n this.privContext.phraseDetection.enrichment.pronunciationAssessment = JSON.parse(params);\n if (isSpeakerDiarizationEnabled) {\n this.privContext.phraseDetection.mode = \"Conversation\";\n }\n this.setWordLevelTimings();\n this.privContext.phraseOutput.detailed.options.push(\"PronunciationAssessment\");\n if (this.privContext.phraseOutput.detailed.options.indexOf(\"SNR\") === -1) {\n this.privContext.phraseOutput.detailed.options.push(\"SNR\");\n }\n if (!!contentAssessmentTopic) {\n this.privContext.phraseDetection.enrichment.contentAssessment = {\n topic: contentAssessmentTopic\n };\n this.privContext.phraseOutput.detailed.options.push(\"ContentAssessment\");\n }\n }\n setDetailedOutputFormat() {\n if (this.privContext.phraseOutput === undefined) {\n this.privContext.phraseOutput = {\n detailed: {\n options: []\n },\n format: {}\n };\n }\n if (this.privContext.phraseOutput.detailed === undefined) {\n this.privContext.phraseOutput.detailed = {\n options: []\n };\n }\n this.privContext.phraseOutput.format = \"Detailed\";\n }\n setWordLevelTimings() {\n if (this.privContext.phraseOutput === undefined) {\n this.privContext.phraseOutput = {\n detailed: {\n options: []\n },\n format: {}\n };\n }\n if (this.privContext.phraseOutput.detailed === undefined) {\n this.privContext.phraseOutput.detailed = {\n options: []\n };\n }\n this.privContext.phraseOutput.format = \"Detailed\";\n if (this.privContext.phraseOutput.detailed.options.indexOf(\"WordTimings\") === -1) {\n this.privContext.phraseOutput.detailed.options.push(\"WordTimings\");\n }\n }\n setSpeakerDiarizationAudioOffsetMs(audioOffsetMs) {\n this.privContext.phraseDetection.speakerDiarization.audioOffsetMs = audioOffsetMs;\n }\n toJSON() {\n const dgi = this.privDynamicGrammar.generateGrammarObject();\n this.setSection(\"dgi\", dgi);\n const ret = JSON.stringify(this.privContext);\n return ret;\n }\n}\nexports.SpeechContext = SpeechContext;","map":{"version":3,"names":["Object","defineProperty","exports","value","SpeechContext","constructor","dynamicGrammar","privContext","privDynamicGrammar","getSection","sectionName","setSection","setPronunciationAssessmentParams","params","contentAssessmentTopic","isSpeakerDiarizationEnabled","phraseDetection","undefined","enrichment","pronunciationAssessment","JSON","parse","mode","setWordLevelTimings","phraseOutput","detailed","options","push","indexOf","contentAssessment","topic","setDetailedOutputFormat","format","setSpeakerDiarizationAudioOffsetMs","audioOffsetMs","speakerDiarization","toJSON","dgi","generateGrammarObject","ret","stringify"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/microsoft-cognitiveservices-speech-sdk/distrib/lib/src/common.speech/SpeechContext.js"],"sourcesContent":["\"use strict\";\n// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.SpeechContext = void 0;\n/**\n * Represents the JSON used in the speech.context message sent to the speech service.\n * The dynamic grammar is always refreshed from the encapsulated dynamic grammar object.\n */\nclass SpeechContext {\n constructor(dynamicGrammar) {\n this.privContext = {};\n this.privDynamicGrammar = dynamicGrammar;\n }\n /**\n * Gets a section of the speech.context object.\n * @param sectionName Name of the section to get.\n * @return string or Context JSON serializable object that represents the value.\n */\n getSection(sectionName) {\n return (this.privContext[sectionName] || {});\n }\n /**\n * Adds a section to the speech.context object.\n * @param sectionName Name of the section to add.\n * @param value JSON serializable object that represents the value.\n */\n setSection(sectionName, value) {\n this.privContext[sectionName] = value;\n }\n /**\n * @Internal\n * This is only used by pronunciation assessment config.\n * Do not use externally, object returned will change without warning or notice.\n */\n setPronunciationAssessmentParams(params, contentAssessmentTopic, isSpeakerDiarizationEnabled = false) {\n if (this.privContext.phraseDetection === undefined) {\n this.privContext.phraseDetection = {\n enrichment: {\n pronunciationAssessment: {}\n }\n };\n }\n if (this.privContext.phraseDetection.enrichment === undefined) {\n this.privContext.phraseDetection.enrichment = {\n pronunciationAssessment: {}\n };\n }\n this.privContext.phraseDetection.enrichment.pronunciationAssessment = JSON.parse(params);\n if (isSpeakerDiarizationEnabled) {\n this.privContext.phraseDetection.mode = \"Conversation\";\n }\n this.setWordLevelTimings();\n this.privContext.phraseOutput.detailed.options.push(\"PronunciationAssessment\");\n if (this.privContext.phraseOutput.detailed.options.indexOf(\"SNR\") === -1) {\n this.privContext.phraseOutput.detailed.options.push(\"SNR\");\n }\n if (!!contentAssessmentTopic) {\n this.privContext.phraseDetection.enrichment.contentAssessment = {\n topic: contentAssessmentTopic\n };\n this.privContext.phraseOutput.detailed.options.push(\"ContentAssessment\");\n }\n }\n setDetailedOutputFormat() {\n if (this.privContext.phraseOutput === undefined) {\n this.privContext.phraseOutput = {\n detailed: {\n options: []\n },\n format: {}\n };\n }\n if (this.privContext.phraseOutput.detailed === undefined) {\n this.privContext.phraseOutput.detailed = {\n options: []\n };\n }\n this.privContext.phraseOutput.format = \"Detailed\";\n }\n setWordLevelTimings() {\n if (this.privContext.phraseOutput === undefined) {\n this.privContext.phraseOutput = {\n detailed: {\n options: []\n },\n format: {}\n };\n }\n if (this.privContext.phraseOutput.detailed === undefined) {\n this.privContext.phraseOutput.detailed = {\n options: []\n };\n }\n this.privContext.phraseOutput.format = \"Detailed\";\n if (this.privContext.phraseOutput.detailed.options.indexOf(\"WordTimings\") === -1) {\n this.privContext.phraseOutput.detailed.options.push(\"WordTimings\");\n }\n }\n setSpeakerDiarizationAudioOffsetMs(audioOffsetMs) {\n this.privContext.phraseDetection.speakerDiarization.audioOffsetMs = audioOffsetMs;\n }\n toJSON() {\n const dgi = this.privDynamicGrammar.generateGrammarObject();\n this.setSection(\"dgi\", dgi);\n const ret = JSON.stringify(this.privContext);\n return ret;\n }\n}\nexports.SpeechContext = SpeechContext;\n\n"],"mappings":"AAAA,YAAY;;AACZ;AACA;AACAA,MAAM,CAACC,cAAc,CAACC,OAAO,EAAE,YAAY,EAAE;EAAEC,KAAK,EAAE;AAAK,CAAC,CAAC;AAC7DD,OAAO,CAACE,aAAa,GAAG,KAAK,CAAC;AAC9B;AACA;AACA;AACA;AACA,MAAMA,aAAa,CAAC;EAChBC,WAAWA,CAACC,cAAc,EAAE;IACxB,IAAI,CAACC,WAAW,GAAG,CAAC,CAAC;IACrB,IAAI,CAACC,kBAAkB,GAAGF,cAAc;EAC5C;EACA;AACJ;AACA;AACA;AACA;EACIG,UAAUA,CAACC,WAAW,EAAE;IACpB,OAAQ,IAAI,CAACH,WAAW,CAACG,WAAW,CAAC,IAAI,CAAC,CAAC;EAC/C;EACA;AACJ;AACA;AACA;AACA;EACIC,UAAUA,CAACD,WAAW,EAAEP,KAAK,EAAE;IAC3B,IAAI,CAACI,WAAW,CAACG,WAAW,CAAC,GAAGP,KAAK;EACzC;EACA;AACJ;AACA;AACA;AACA;EACIS,gCAAgCA,CAACC,MAAM,EAAEC,sBAAsB,EAAEC,2BAA2B,GAAG,KAAK,EAAE;IAClG,IAAI,IAAI,CAACR,WAAW,CAACS,eAA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