@voice-ping/cognitive-services-speech
Version:
VoicePing Cognitive Services Speech SDK for JavaScript forked from Microsoft
29 lines (27 loc) • 959 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 serializable 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