有人知道如何在此tts powershell命令中更改声音吗?-Powershell Command Add-Type -AssemblyName System.Speech$Speaker = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer$Speaker.Speak(oh my...

有人知道如何在此tts powershell命令中更改声音吗?
-Powershell Command Add-Type -AssemblyName System.Speech
$Speaker = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer
$Speaker.Speak('oh my god, I can now talk; it''s amazing!')
它需要尽可能小,因为我正在使用pythons os.system()命令实现此功能
解决方法:
我的仓库中脚本的快速翻译:
## SelVoiceSpeak.ps1
Add-Type -AssemblyName "System.Speech"
$speaker = new-object System.Speech.Synthesis.SpeechSynthesizer
$speaker.SetOutputToDefaultAudioDevice()
write-host "These voices are installed:`r`n" -ForegroundColor Yellow -BackgroundColor Black
$cntr = 0;
$voices = $speaker.GetInstalledVoices() | Where Enabled | ForEach VoiceInfo
$voices | %{$cntr++;write-host "[$cntr] $($_.Name)" -ForegroundColor Green}
$choice = Read-Host "`r`nChoose a name [1-$($voices.length)]"
if ($choice -gt 0 -and $choice -le $voices.length){
$voice = $voices[$choice -1].Name
$speaker.SelectVoice($voice)
} else {
write-Host "no valid choice" -ForegroundColor Red
exit
}
$text = Read-Host "`r`nEnter text to speak"
write-host "`r`nspeaking now!" -BackgroundColor DarkCyan -ForegroundColor White
$speaker.Speak($text)
丑陋的颜色,示例输出:
> .\SelVoiceSpeak.ps1
These voices are installed:
[1] Microsoft Hedda Desktop
[2] Microsoft Zira Desktop
Choose a name [1-2]: 2
Enter text to speak: hello world!
speaking now!
编辑:一个没有任何检查的最小脚本,
说固定的声音和固定的文字,可以与“;”连接到一行:
Add-Type -AssemblyName "System.Speech"
$speaker = new-object System.Speech.Synthesis.SpeechSynthesizer
$speaker.SelectVoice("Microsoft David Desktop")
$speaker.Speak("This is a text")
沃梦达教程
本文标题为:使用python更改powershell tts命令讲述人


基础教程推荐
猜你喜欢
- Python面向对象之模块详解 2023-08-11
- Ubuntu16.04切换python3和python2 2023-09-04
- Python之路-Python中的线程与进程 2023-09-04
- jupyter notebook添加python内核(windows) 2023-09-03
- python列表中remove()函数的使用方法详解 2023-08-09
- Python 切片为什么不会索引越界? 2023-08-11
- python通过内置模块监控磁盘、内存、CPU、负载 2023-09-03
- Python YAML文件的读写操作详解 2022-08-30
- Python——进程队列 2023-09-03
- python中defaultdict用法实例详解 2022-10-20