microsoft-cognitiveservices-speech-sdk
Version:
Microsoft Cognitive Services Speech SDK for JavaScript
49 lines (47 loc) • 1.51 kB
JavaScript
;
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.SpeechSynthesisRequestInputStream = void 0;
/**
* Represents an input stream for speech synthesis request text streaming.
* Note: This class is in preview and may be subject to change in future versions.
* @class SpeechSynthesisRequestInputStream
*/
class SpeechSynthesisRequestInputStream {
/**
* Constructor for internal use.
* @param parent The parent SpeechSynthesisRequest.
*/
constructor(parent) {
this.privClosed = false;
this.privParent = parent;
}
/**
* Writes the specified text to the input stream.
* @param text The text to be written to the input stream.
*/
write(text) {
if (this.privClosed) {
throw new Error("Cannot write to a closed input stream.");
}
this.privParent.onTextPieceReceived(text);
}
/**
* Closes the input stream, signaling that no more text will be written.
*/
close() {
if (!this.privClosed) {
this.privClosed = true;
this.privParent.onInputStreamClosed();
}
}
/**
* Gets whether the input stream is closed.
*/
get isClosed() {
return this.privClosed;
}
}
exports.SpeechSynthesisRequestInputStream = SpeechSynthesisRequestInputStream;
//# sourceMappingURL=SpeechSynthesisRequestInputStream.js.map