我正在 VBA 中使用 AWS Polly 进行试验,我想将默认文本更改为“嗨!我的名字是 Salli。我会阅读您在此处键入的任何文本。” 到“这是一条测试消息”。然后让 Salli 阅读它。我可以编写代码来更改文本,但 Salli 总是读取相同的默认文本。textarea 框下的剩余字符数计数器也没有更新。
这是我的代码。
Dim objIE As Object
Set objIE = CreateObject("InternetExplorer.Application")
'navigate to aws polly site
With objIE
.Top = 0
.Left = 0
.Width = 800
.Height = 600
.Visible = True
End With
objIE.navigate ("https://us-east-2.console.aws.amazon.com/polly/home/SynthesizeSpeech")
Do
DoEvents
If Err.Number <> 0 Then
objIE.Quit
Set objIE = Nothing
GoTo the_start:
End If
Loop Until objIE.readyState = 4
Dim polly As HTMLDocument
Dim narrative As HTMLLIElement
Dim btnReadText As HTMLButtonElement
Set polly = objIE.document
Set narrative = polly.getElementById("awsui-textarea-0")
Set btnReadText = polly.getElementsByClassName("parrot-player-button full-width-button awsui-button awsui-button-size-normal awsui-button-variant-primary awsui-hover-child-icons")(0)
narrative.Focus
narrative.innerHTML = "This is a new test message."
MsgBox narrative.innerHTML
btnReadText.Click
这个片段执行没有错误,但 Salli 总是说同样的话。