简体   繁体   English

从 url 播放声音 - Node.JS (Google-TTS)

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

I am trying to use the google text to speech API in Node.JS.我正在尝试在 Node.JS 中使用谷歌文本到语音 API。 I am generating api links using google-tts-api and want to play them now.我正在使用 google-tts-api 生成 api 链接,现在想播放它们。 Is there any node library, that is able to play sound from a weblink?是否有任何节点库可以从网络链接播放声音?

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.
}

If you just want the URL you can try calling ffplay as a child process.如果您只想要 URL,您可以尝试将ffplay作为子进程调用。 But if you just are looking for having node talk to you try say.js or tts .但是,如果您只是想与 node 对话,请尝试say.jstts If you get raw audio (by decoding raw PCM Audio) you can use node-speaker .如果您获得原始音频(通过解码原始 PCM 音频),您可以使用node-speaker

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM