我希望能够为我的文本转语音输出选择替代语音。
\n我正在使用 ComObject SAPI.SPVoice,但我发现我无法更改实际使用的语音。
\n(顺便说一句 - 我正在使用 SAPI.SPVoice,因为它适用于 Windows 10 上的 PowerShell Core 和 PowerShell Desktop)
${PromptTTS} = New-Object -ComObject SAPI.SPVoice\nRun Code Online (Sandbox Code Playgroud)\n\n\xe2\x9d\xaf $PromptTTS | gm\nRun Code Online (Sandbox Code Playgroud)\n\n TypeName: System.__ComObject#{269316d8-57bd-11d2-9eee-00c04f797396}\n\nName MemberType Definition\n---- ---------- ----------\nDisplayUI Method void DisplayUI (int hWndParent, string Title, string TypeOfUI, Variant ExtraData)\nGetAudioOutputs Method ISpeechObjectTokens GetAudioOutputs (string RequiredAttributes, string OptionalAttributes)\nGetVoices Method ISpeechObjectTokens GetVoices (string RequiredAttributes, string OptionalAttributes)\nIsUISupported Method bool IsUISupported (string TypeOfUI, Variant ExtraData)\nPause Method void Pause ()\nResume Method void Resume ()\nSkip Method int Skip (string Type, int …Run Code Online (Sandbox Code Playgroud) 我以前使用过 Microsoft Speech(不确定它是哪个版本).net framework并且它确实有效。我的电脑上现在没有那个项目。我已经下载并安装了Runtime 11和SDK 11,并.dll在我的.net core 3.0项目中从C:\Program Files\Microsoft SDKs\Speech\v11.0\Assembly\Microsoft.Speech.dll. 这是我现在在我的 ViewModel 中的内容:
.
.
.
using Microsoft.Speech.Synthesis;
namespace Read
{
public class VM : INotifyPropertyChanged
{
SpeechSynthesizer synth;
string inputText;
public string InputText { get => inputText; set { inputText = value; OnPropertyChanged(); } }
public Command Speak { get; set; }
public Command Pause { get; set; }
public Command Resume { get; set; }
public …Run Code Online (Sandbox Code Playgroud)