如此处所示(请原谅法语用户界面),我的计算机上安装了3个文本到语音的声音:
但是,当我跑:
Add-Type -AssemblyName System.Speech
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
$speak.GetInstalledVoices().VoiceInfo
它只返回“Microsoft Zira Desktop”:
Gender : Female Age : Adult Name : Microsoft Zira Desktop Culture : en-US Id : TTS_MS_EN-US_ZIRA_11.0 Description : Microsoft Zira Desktop - English (United States) SupportedAudioFormats : {} AdditionalInfo : {[Age, Adult], [Gender, Female], [Language, 409], [Name, Microsoft Zira Desktop]...}
我的目标是能够列出所有已安装的语音,然后使用PowerShell选择一个。
我真的很困惑为什么声音工作并且可以在UI中选择而不是通过PowerShell?
感谢Jeff Zeitlin指出我正确的方向!
您必须将语音复制到注册表中的不同路径。来自GitHub的这个脚本可以解决这个问题:)现在可以在PowerShell和其他第三方程序中使用和选择所有语音!
$sourcePath = 'HKLM:\software\Microsoft\Speech_OneCore\Voices\Tokens' #Where the OneCore voices live
$destinationPath = 'HKLM:\SOFTWARE\Microsoft\Speech\Voices\Tokens' #For 64-bit apps
$destinationPath2 = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\SPEECH\Voices\Tokens' #For 32-bit apps
cd $destinationPath
$listVoices = Get-ChildItem $sourcePath
foreach($voice in $listVoices)
{
$source = $voice.PSPath #Get the path of this voices key
copy -Path $source -Destination $destinationPath -Recurse
copy -Path $source -Destination $destinationPath2 -Recurse
}
https://gist.github.com/hiepxanh/8b6ad80f6d620cd3eaaaa5c1d2c660b2
详细解释:https://www.reddit.com/r/Windows10/comments/96dx8z/how_unlock_all_windows_10_hidden_tts_voices_for/