When attempting to convert an mp3 to wav using npm mp3-to-wav
, the console returns,
"mp3 to wav exec err: saveForWav err: Path must be a string. Received [ 'C:\\Projects\\Weatherman\\meme.wav' ]"
I'm fairly certain what I'm feeding it is a string, so I have not a clue where the problem lies. npm mp3-to-wav
can be found at https://www.npmjs.com/package/mp3-to-wav#2-usage and here's my code.
const Mp32Wav = require('mp3-to-wav');
new Mp32Wav("C:/Projects/Weatherman/meme.MP3").exec()
How do I get the file to receive the directory path and is there a problem with my directory path?
the err you get is not from 'mp3-to-wav' its from fs
there isnt any problem with your path
class Mp32Wav {
constructor(input_file_path, output_dir) {
if (!utils.checkArgsNotNull(...input_file_path)) {
throw new Error('err arguments')
}
output_dir = utils.judgeNotNull(output_dir) ? output_dir : utils.splitFileDir(input_file_path)
this._input_file_path = input_file_path
this._input_file_name = utils.splitFilename(input_file_path)
this._output_dir = output_dir
this._output_file_name = this._input_file_name.toString().replace(/\.mp3/i, '')
}
as you can see in their constructor they ignore case sensitive
.replace(/\.mp3/i, '')
I don't use windows but I think it will be helpful for you to use path module to create your path and check if its absolute
Node.js path.isAbsolute() Method
https://www.w3schools.com/nodejs/met_path_isabsolute.asp
also, all examples in w3c use double \\\\ insted of \\ in windows
for example
console.log(path.isAbsolute('C:\\test\\demo_path.js')); //true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.