题
是否有办法使用MS讲话用从命令行?我可以做一个mac,但找不到任何参照它在Windows XP。
谢谢。
解决方案
其他提示
我对这个主题的 2 美分,命令行俏皮话:
在 Win 上使用
PowerShell.exe
PowerShell -Command "Add-Type –AssemblyName System.Speech; (New-Object System.Speech.Synthesis.SpeechSynthesizer).Speak('hello');"
在 Win 上使用
mshta.exe
mshta vbscript:Execute("CreateObject(""SAPI.SpVoice"").Speak(""Hello"")(window.close)")
在 OSX 上使用
say
say "hello"
使用本机的 Ubuntu 桌面 (>=2015)
spd-say
spd-say "hello"
在任何其他 Linux 上
- 参考 如何使用命令行进行文本转语音输出?
- 命令行函数 使用谷歌 TTS (wget 到 mp3->mplayer)
在 Raspberry Pi、Win、OSX 上使用 节点红
npm i 节点红色贡献系统消息
有一个不错的开源的程序,做你要求在Windows什么叫彼得的文本可在这里演讲:的 http://jampal.sourceforge.net/ptts.html
它包含一个名为ptts.exe会说话从标准输入文本二进制文件,这样你就可以像这样运行:
echo hello there | ptts.exe
另外,你可以使用以下三种线VBS脚本来获得类似的基本TTS:
'say.vbs
set s = CreateObject("SAPI.SpVoice")
s.Speak Wscript.Arguments(0), 3
s.WaitUntilDone(1000)
和你可以调用该命令行是这样的:
cscript say.vbs "hello there"
如果你走的路线脚本,你可能会想找到一个可变的超时和错误处理一些更广泛的代码示例。
希望它能帮助。
rem The user decides what to convert here
:input
cls
echo Type in what you want the computer to say and then press the enter key.
echo.
set /p text=
rem Making the temp file
:num
set num=%random%
if exist temp%num%.vbs goto num
echo ' > "temp%num%.vbs"
echo set speech = Wscript.CreateObject("SAPI.spVoice") >> "temp%num%.vbs"
echo speech.speak "%text%" >> "temp%num%.vbs"
start temp%num%.vbs
pause
del temp%num%.vbs
goto input
pause
如果你不能找到命令你可以始终包裹 系统。讲话。合成。SpeechSynthesizer 从。净3.0(不要忘了参考"系统。语音")
using System.Speech.Synthesis;
namespace Talk
{
class Program
{
static void Main(string[] args)
{
using (var ss = new SpeechSynthesizer())
foreach (var toSay in args)
ss.Speak(toSay);
}
}
}
还有一种方式的powershell:
创建一个名为speak.ps1文件
param([string]$inputText)
Add-Type –AssemblyName System.Speech
$synth = New-Object System.Speech.Synthesis.SpeechSynthesizer
$synth.Speak($inputText);
然后,可以调用它
.\speak.ps1 "I'm sorry Dave, I'm afraid I can't do that"
您最好的办法是写一个小的命令行实用工具,将你做它。它不会是大量的工作 - 只是阅读文本,然后使用MS TTS库
另一种替代方法是使用倒谱系。它配备了一个不错的命令行实用工具和声音光年比MS TTS更好。
还有 巴拉博尔卡: http://www.cross-plus-a.com/bconsole.htm它有一个命令行工具 balcon.exe
. 。你可以这样使用它:
列出声音:
balcon.exe -l
讲文件:
balcon.exe -n "IVONA 2 Jennifer" -f file.txt
从命令行说话:
balcon.exe -n "IVONA 2 Jennifer" -t "hello there"
有更多命令行选项可用。我在 Ubuntu 上尝试过,并在 Wine 中安装了 SAPI5。它工作得很好。