Return Stream wrapper in JS Model.createStream

This commit is contained in:
Reuben Morais 2020-04-29 13:43:28 +02:00
parent d120c4096a
commit b0415af4b4
2 changed files with 6 additions and 6 deletions

View File

@ -112,7 +112,7 @@ sttWithMetadata(aBuffer: object, aNumResults: number): Metadata;
*
* @throws on error
*/
createStream(): object;
createStream(): Stream;
}
/**
@ -127,14 +127,14 @@ declare class Stream {
* @param aBuffer An array of 16-bit, mono raw audio samples at the
* appropriate sample rate (matching what the model was trained on).
*/
feedAudioContent(aBuffer: object): void;
feedAudioContent(aBuffer: Buffer): void;
/**
* Compute the intermediate decoding of an ongoing streaming inference.
*
* @return The STT intermediate result.
*/
intermediateDecode(aSctx: object): string;
intermediateDecode(aSctx: Stream): string;
/**
* Compute the intermediate decoding of an ongoing streaming inference, return results including metadata.
@ -188,7 +188,7 @@ export function FreeMetadata(metadata: Metadata): void;
*
* @param stream A streaming state pointer returned by :js:func:`Model.createStream`.
*/
export function FreeStream(stream: object): void;
export function FreeStream(stream: Stream): void;
/**
* Print version of this library and of the linked TensorFlow library on standard output.

View File

@ -141,7 +141,7 @@ Model.prototype.createStream = function() {
if (status !== 0) {
throw "CreateStream failed "+binding.ErrorCodeToErrorMessage(status)+" 0x" + status.toString(16);
}
return ctx;
return new Stream(ctx);
}
/**
@ -192,7 +192,7 @@ Stream.prototype.intermediateDecodeWithMetadata = function(aNumResults) {
* This method will free the stream, it must not be used after this method is called.
*/
Stream.prototype.finishStream = function() {
result = binding.FinishStream(this._impl);
let result = binding.FinishStream(this._impl);
this._impl = null;
return result;
}