aws-samples / aws-samples/aws-nodejs-sample
TypeError: TypeError: path must be a string or Buffer when calling
- Dominant language
- JavaScript
- Stars
- 306
- Forks
- 168
- PR merge metrics
- No merged PRs in 30d
Description
I'm having trouble while calling Polly.
`Polly.synthesizeSpeech(params, (err, data) => {
if (err) {
console.log(err.code)
} else if (data) {
if (data.AudioStream instanceof Buffer) {
Fs.writeFile(argv.mp3, data.AudioStream, (err)=> {
if (err) {
return console.log(err)
}
console.log("The file was saved!")
var output = child_process.execSync('lame --decode ' + argv.mp3 + ' ' + '-b 8000' + ' ' + argv.wav + '.wav');
})
}
}
})
`
/opt/aws-nodejs-sample/node_modules/aws-sdk/lib/request.js:31
throw err;
^
TypeError: path must be a string or Buffer
at TypeError (native)
at Object.fs.open (fs.js:631:11)
at Object.fs.writeFile (fs.js:1303:6)
at Response. (/opt/aws-nodejs-sample/script.js:29:4)
at Request. (/opt/aws-nodejs-sample/node_modules/aws-sdk/lib/request.js:364:18)
at Request.callListeners (/opt/aws-nodejs-sample/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/opt/aws-nodejs-sample/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/opt/aws-nodejs-sample/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/opt/aws-nodejs-sample/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/opt/aws-nodejs-sample/node_modules/aws-sdk/lib/state_machine.js:14:12)
I have no idea how to fix this.
Contributor guide
Research direction
Start at script.js line 29, where the stack trace points to Fs.writeFile, and inspect how argv.mp3 is populated before the Polly.synthesizeSpeech callback. Reproduce the call with a valid output path and confirm the sample handles the audio response without the path TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, javascript, node.js
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100