播放来自 url - Node.JS (Google-TTS) 的声音

Playing sound from url - Node.JS (Google-TTS)

我正在尝试在 Node.JS 中使用 google 文本转语音 API。我正在使用 google-tts-api 生成 api 链接,现在想播放它们。是否有任何节点库能够从网络链接播放声音?

var tts = require("google-tts-api");
tts(text, "de-DE", 1).then(function(url) {
  playSound(url);
});
function playSound(url) {
  //Some code, that is able to play the audio from the url.
}

如果您只想要 URL,您可以尝试将 ffplay 作为子进程调用。 但是,如果您只是想让节点与您交谈,请尝试 say.js or tts. If you get raw audio (by decoding raw PCM Audio) you can use node-speaker.