IBM Watson TextToSpeech: no se puede leer la propiedad .pipe de undefined
Tengo el siguiente código, directamente de la documentación:
var TextToSpeechV1 = require('watson-developer-cloud/text-to-
speech/v1');
var fs = require('fs');
var textToSpeech = new TextToSpeechV1({
iam_apikey: '---myapikey---',
url: 'https://stream.watsonplatform.net/text-to-speech/api/'
});
var synthesizeParams = {
text: 'Hello world, you dummy ass',
accept: 'audio/wav',
voice: 'en-US_AllisonVoice'
};
// Pipe the synthesized text to a file.
textToSpeech.synthesize(synthesizeParams).on('error', function(error) {
console.log(error);
}).pipe(fs.createWriteStream('hello_world.wav'));
cuando lo ejecuto, me da el siguiente error:
pi@raspberrypi:~/Desktop/tjbotcz_lite $ sudo node ttstest.js
/home/pi/Desktop/tjbotcz_lite/ttstest.js:16
textToSpeech.synthesize(synthesizeParams).on('error', function(error) {
^
TypeError: Cannot read property 'on' of undefined
at Object.<anonymous> (/home/pi/Desktop/tjbotcz_lite/ttstest.js:16:42)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
at startup (internal/bootstrap/node.js:201:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)
¿Alguna pista de por qué? Tengo el mismo problema con TJBot, así que probé un ejemplo simple de documentación y listo: el mismo error. Cuando uso mi antiguo servicio (con nombre de usuario y contraseña, no clave de API) funciona bien. Tengo la nueva versión de la biblioteca watson-cloud (3.13.1).
Gracias por cualquier pista. Saludos, enero