【发布时间】:2020-12-06 03:31:38
【问题描述】:
JavaScript 的内置文本转语音功能是SpeechSynthesis.speak()。我正在使用 discord.js,我想将 Speech Synthesis 转换为 node.js Readable Stream,以便将其作为广播播放到语音频道。
我确实找到了 this 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 中使用的可读流?如果是这样,怎么做?或者,有没有办法使用以前的回购?请帮帮我,不胜感激。
(另外,我知道 discord 有一个内置的 tts 按钮用于阅读消息 - 这是完全不同的东西)
【问题讨论】:
标签: javascript node.js discord.js text-to-speech