Merge pull request #3011 from mozilla/pr3010
PR #3010 - Fix Stream.intermediateDecodeWithMetadata + tests
This commit is contained in:
commit
0ed7d301e3
@ -132,6 +132,12 @@ if (!args['stream']) {
|
|||||||
let stream = model.createStream();
|
let stream = model.createStream();
|
||||||
conversionStream.on('data', (chunk: Buffer) => {
|
conversionStream.on('data', (chunk: Buffer) => {
|
||||||
stream.feedAudioContent(chunk);
|
stream.feedAudioContent(chunk);
|
||||||
|
if (args['extended']) {
|
||||||
|
let metadata = stream.intermediateDecodeWithMetadata();
|
||||||
|
console.error('intermediate: ' + candidateTranscriptToString(metadata.transcripts[0]));
|
||||||
|
} else {
|
||||||
|
console.error('intermediate: ' + stream.intermediateDecode());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
conversionStream.on('end', () => {
|
conversionStream.on('end', () => {
|
||||||
if (args['extended']) {
|
if (args['extended']) {
|
||||||
|
6
native_client/javascript/index.d.ts
vendored
6
native_client/javascript/index.d.ts
vendored
@ -90,7 +90,7 @@ setScorerAlphaBeta(aLMAlpha: number, aLMBeta: number): number;
|
|||||||
*
|
*
|
||||||
* @return The STT result. Returns undefined on error.
|
* @return The STT result. Returns undefined on error.
|
||||||
*/
|
*/
|
||||||
stt(aBuffer: object): string;
|
stt(aBuffer: Buffer): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use the DeepSpeech model to perform Speech-To-Text and output metadata
|
* Use the DeepSpeech model to perform Speech-To-Text and output metadata
|
||||||
@ -103,7 +103,7 @@ stt(aBuffer: object): string;
|
|||||||
* @return :js:func:`Metadata` object containing multiple candidate transcripts. Each transcript has per-token metadata including timing information.
|
* @return :js:func:`Metadata` object containing multiple candidate transcripts. Each transcript has per-token metadata including timing information.
|
||||||
* The user is responsible for freeing Metadata by calling :js:func:`FreeMetadata`. Returns undefined on error.
|
* The user is responsible for freeing Metadata by calling :js:func:`FreeMetadata`. Returns undefined on error.
|
||||||
*/
|
*/
|
||||||
sttWithMetadata(aBuffer: object, aNumResults?: number): Metadata;
|
sttWithMetadata(aBuffer: Buffer, aNumResults?: number): Metadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new streaming inference state. One can then call :js:func:`Stream.feedAudioContent` and :js:func:`Stream.finishStream` on the returned stream object.
|
* Create a new streaming inference state. One can then call :js:func:`Stream.feedAudioContent` and :js:func:`Stream.finishStream` on the returned stream object.
|
||||||
@ -134,7 +134,7 @@ feedAudioContent(aBuffer: Buffer): void;
|
|||||||
*
|
*
|
||||||
* @return The STT intermediate result.
|
* @return The STT intermediate result.
|
||||||
*/
|
*/
|
||||||
intermediateDecode(aSctx: Stream): string;
|
intermediateDecode(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the intermediate decoding of an ongoing streaming inference, return results including metadata.
|
* Compute the intermediate decoding of an ongoing streaming inference, return results including metadata.
|
||||||
|
@ -184,7 +184,7 @@ Stream.prototype.intermediateDecode = function() {
|
|||||||
*/
|
*/
|
||||||
Stream.prototype.intermediateDecodeWithMetadata = function(aNumResults) {
|
Stream.prototype.intermediateDecodeWithMetadata = function(aNumResults) {
|
||||||
aNumResults = aNumResults || 1;
|
aNumResults = aNumResults || 1;
|
||||||
return binding.IntermediateDecode(this._impl, aNumResults);
|
return binding.IntermediateDecodeWithMetadata(this._impl, aNumResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user