问题描述
在VBA中,我有一个按钮,当我单击它时,它应该为我提供文本框荷兰语的语音文本。
在Windows /控制面板/语音识别/语音文本中,我有两种语言(Bart-Dutch / Zira-English),但是在VBA中,我有以下代码(用于测试),并且我只有一种语言,Zira ,英文的。我该如何让Bart说话?
Dim i As Long
Dim voc As SpeechLib.SpVoice
Set voc = New SpVoice
Debug.Print voc.GetVoices.Count & " available voices:"
For i = 0 To voc.GetVoices.Count - 1
Set voc.Voice = voc.GetVoices.Item(i)
Debug.Print " " & i & " - " & voc.Voice.GetDescription
voc.Speak "test audio"
Next i
1种可用声音: 0-Microsoft Zira Desktop-英文(美国)
解决方法
您是否尝试过使用SelectVoice
方法?您也可以尝试使用SpeakSSML
来强制使用语言-注意xml:lang
属性*(我不会说VB,因此语法可能是错误的):
voc.SpeakSSML '<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="nl">test audio</speak>'
此外,请注意Windows 10具有两个不同的语音子系统,因此根据所使用的库,您可能会获得一组不同的清单。供参考,这是两个使用System.Speech.Synthesis和Windows.Media.SpeechSynthesis
的Powershell示例