say.js
say.js copied to clipboard
Change interface for 1.0?
I'm considering changing interface of speak and export to this:
// locale + flavor + platform automatically pick most appropriate voice
let options = {
"locale": "en-US", // Under the hood determine best voice
"flavor": "masculine", // Masculine, Feminine, Neutral, Robot, etc.
"voice": "Samantha", // Allow exact voice override for power users
"speed": 1.5 // 150% speed
// "filename": "greeting.wav" -> used for export, default to "output.wav"
// "volume": 1.25 -> 125% volume, future values can be easily added
};
say.speak(message, options, callback);
say.speak(message, callback); // options is optional, callback can be 2nd
say.speak(message, options);
say.speak(message); // only message is required
say.export(...); // same as say.speak()
Every option in options would have a sensible default. This allows us to easily collapse arguments.
Also considering exposing Say as an instantiate-able class (check out #62 for more details). We could then provide defaults for the speak and export methods, since they probably don't need to change frequently throughout an applications lifecycle.
const Say = require('say');
let say = new Say({
"locale": "de-DE", // Set defaults for options object
"flavor": "masculine", // Set defaults for options object
"voice": "Anna", // Set defaults for options object
"speed": 0.95, // Set defaults for options object
"volume": 1.25, // Set defaults for options object
"platform": "linux" // Override platform
});
say.speak("I'm sorry, Dave.");