@euirim/microsoft-cognitiveservices-speech-sdk
Version:
Microsoft Cognitive Services Speech SDK for JavaScript
29 lines (27 loc) • 960 B
JavaScript
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
/**
* Represents the JSON used in the speech.context message sent to the speech service.
* The dynamic grammar is always refreshed from the encapsulated dynamic grammar object.
*/
export class SpeechContext {
constructor(dynamicGrammar) {
this.privContext = {};
this.privDynamicGrammar = dynamicGrammar;
}
/**
* Adds a section to the speech.context object.
* @param sectionName Name of the section to add.
* @param value JSON serializeable object that represents the value.
*/
setSection(sectionName, value) {
this.privContext[sectionName] = value;
}
toJSON() {
const dgi = this.privDynamicGrammar.generateGrammarObject();
this.setSection("dgi", dgi);
const ret = JSON.stringify(this.privContext);
return ret;
}
}
//# sourceMappingURL=SpeechContext.js.map