Marak/say.js

Export doesn't work on mac

popo63301 opened this issue · 1 comments

Hi! I try to export a sound with this module. Here is my code:

#!/usr/bin/env node

const say = require('say')

// Use default system voice and speed
say.export("I'm sorry, Dave.", null, 0.75, './whereareyou.wav', (err) => {
  if (err) {
    return console.error(err)
  }

  console.log('Text has been saved to hal.wav.')
})

When I launch my script from terminal with the command "node myfile.js", I can hear "I'm sorry, Dave." but I don't get the sound exported into a file in my folder. Anyone can help?

Okay, I just created a better function myself. Plus, it avoids to listen the text you want to export.

Enjoy:

var exec = require('child_process').exec;


function say(text, voice, nameFile) {
  exec(`say -v ${voice} -o ${nameFile}.wav --data-format=LEF32@22050 "${text}"`, function (error, stdOut, stdErr) {
      // do what you want!
  });
}