Closed josete89 closed 4 years ago
Getting the same error. I am receiving audio from WATSON Cloud service
textToSpeech.synthesize(synthesizeParams)
.then(audio => {
audio.pipe(speaker);
})
.catch(err => {
console.log('err:', err);
});
But it breaks after I receive the second audio.
My solution for this was creating a speaker instance per call
textToSpeech.synthesize(synthesizeParams)
.then(audio => {
const speaker = new Speaker({
channels: 1, // 2 channels
sampleRate: 22050 // 44,100 Hz sample rate
})
audio.pipe(speaker);
})
.catch(err => {
console.log('err:', err);
});
very nice @trafalmejo that helped me as well
This happens when you are writing to the stream after you have ended.
The correct solution is to either create a new Speaker
for each stream you want to pipe, or to pipe with { end: false }
ERROR Error: write after end at writeAfterEnd (/home/pi/RetroPie/homebot/node_modules/speaker/node_modules/readable-stream/lib/_stream_writable.js:222:12) at Speaker.Writable.write (/home/pi/RetroPie/homebot/node_modules/speaker/node_modules/readable-stream/lib/_stream_writable.js:262:20) at Decoder.ondata (/home/pi/RetroPie/homebot/node_modules/readable-stream/lib/_stream_readable.js:572:20)