File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ function infiniteStream(
5959 // const streamingLimit = 10000; // ms - set to low number for demo purposes
6060
6161 const chalk = require ( 'chalk' ) ;
62- const { Transform } = require ( 'stream' ) ;
62+ const { Writable } = require ( 'stream' ) ;
6363
6464 // Node-Record-lpcm16
6565 const recorder = require ( 'node-record-lpcm16' ) ;
@@ -146,8 +146,8 @@ function infiniteStream(
146146 }
147147 } ;
148148
149- const audioInputStreamTransform = new Transform ( {
150- transform : ( chunk , encoding , callback ) => {
149+ const audioInputStreamTransform = new Writable ( {
150+ write ( chunk , encoding , next ) {
151151 if ( newStream && lastAudioInput . length !== 0 ) {
152152 // Approximate math to calculate time of chunks
153153 const chunkTime = streamingLimit / lastAudioInput . length ;
@@ -178,7 +178,13 @@ function infiniteStream(
178178 recognizeStream . write ( chunk ) ;
179179 }
180180
181- callback ( ) ;
181+ next ( ) ;
182+ } ,
183+
184+ final ( ) {
185+ if ( recognizeStream ) {
186+ recognizeStream . end ( ) ;
187+ }
182188 } ,
183189 } ) ;
184190
You can’t perform that action at this time.
0 commit comments