繁体   English   中英

JS 语音合成到 Node.JS 可读 Stream

[英]JS Speech Synthesis to Node.JS Readable Stream

JavaScript 的内置文本转语音 function 是SpeechSynthesis.speak() 我正在使用 discord.js 并且我想将语音合成转换为 node.js 可读 Stream以便我可以将其作为广播播放到语音频道。

我确实找到了这个 Github Repo ,但是它对我不起作用,而且我很难广播它(另外,虽然我不是 100% 确定,但我假设它记录了 tts,这在处理大的文本字符串)。

这是我在使用上述代码时遇到的主要错误:

The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.

Uncaught TypeError: Cannot read property 'getUserMedia' of undefined

我的目标是避免使用 Google 的 tts API 之类的东西,而只使用本机 JavaScript。 是否有可能将语音合成转换为可以在 discord.js 中使用的可读 Stream? 如果是这样,怎么做? 或者,有没有办法使用以前的回购? 请帮助我,将不胜感激。

(另外,我知道 discord 有一个用于阅读消息的内置 tts 按钮 - 这是完全不同的东西)

the Web Speech API (SpeechSynthesis.speak()) uses the underlying OS or Browser synthesis implementation, and doesn't go through the Web Audio API. 该 Github 存储库实际上使用您系统的麦克风来录制语音 output。 除了作为黑客之外,这不是一个好主意。 您需要使用其他东西来生成内容 - 也许Say.js是跨浏览器并直接在 node.js 中工作?

暂无
暂无

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

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