我正在网上搜索有关如何通过 javascript 使用 SAPI 语音识别的信息。更具体地说,我想创建一个可以在本地服务器(可能无法访问互联网)上工作的 Web 应用程序,它将文本转换为语音。
我找到了一些示例Link 1,Link 2但没有一个有效。有什么可行的例子吗?有没有其他方法可以在 Web 应用程序中执行此操作(无需 Internet 连接)?
SAPI objects are "not safe for scripting", and while you can use SAPI from javascript, you have to turn off a lot of security settings, as well as putting the web host into the trusted sites zone. I've done this for a demo, but it's nothing I'd care to allow outside the confines of my own laptop.
Alternatively, Windows 8.1 has javascript TTS bindings through the Windows.Media.SpeechSynthesis namespace.
Another option would be to build an HTML Application; this environment allows unrestricted access to all ActiveX objects.