You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows 10系统下Node.js环境如何获取所有已安装的语音列表

Windows 10 Node.js环境获取系统语音列表解决方案

问题根因

say.js的getInstalledVoices为错误优先回调设计,你调用时传入了回调参数,方法此时不会返回Promise实例,因此await拿到的返回值为null,回调正常打印是因为回调逻辑本身执行正常。

say.js原生单行实现

直接省略回调参数,方法会自动返回Promise,直接await接收即可:

const voices = await say.getInstalledVoices();

无第三方依赖替代实现

如果不想依赖say.js,可以直接调用系统PowerShell接口获取语音列表,无需安装额外包:

const voices = JSON.parse(require('child_process').execSync('powershell "Add-Type -AssemblyName System.Speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).GetInstalledVoices().VoiceInfo | ConvertTo-Json"'))

该方案返回的语音属性更完整,包含语音名称、对应语言区域、性别、年龄等字段,兼容性更强。

内容的提问来源于stack exchange,提问作者Bragon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.05 20:12:01