问题描述
我一直在尝试添加下拉菜单以从 var SpeechParams 中选择 VoiceId(“Matthew”、“Joanna”...),但似乎不起作用。
<html>
<head>
<Meta charset="UTF-8">
<title>AWS SDK for JavaScript - browser Getting Started Application</title>
</head>
<body>
<div id="textToSynth">
<input autofocus size="23" type="text" id="textEntry" value="It's very good to meet you."/>
<button class="btn default" onClick="speakText()">Synthesize</button>
<p id="result">Enter text above then click Synthesize</p>
</div>
<audio id="audioPlayback" controls>
<source id="audioSource" type="audio/mp3" src="">
</audio>
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.410.0.min.js"></script>
<!-- snippet-start:[Polly.HTML.browserExample.config] -->
<script type="text/javascript">
// Initialize the Amazon Cognito credentials provider
AWS.config.region = 'REGION';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({IdentityPoolId: 'IDENTITY_POOL_ID'});
// Function invoked by button click
function speakText() {
// Create the JSON parameters for getSynthesizeSpeechUrl
var speechParams = {
OutputFormat: "mp3",SampleRate: "16000",Text: "",TextType: "text",VoiceId: "Matthew"
};
speechParams.Text = document.getElementById("textEntry").value;
// snippet-end:[Polly.HTML.browserExample.config]
// snippet-start:[Polly.HTML.browserExample.synthesize]
// Create the Polly service object and presigner object
var polly = new AWS.Polly({apiVersion: '2016-06-10'});
var signer = new AWS.Polly.Presigner(speechParams,polly)
// Create presigned URL of synthesized speech file
signer.getSynthesizeSpeechUrl(speechParams,function(error,url) {
if (error) {
document.getElementById('result').innerHTML = error;
} else {
document.getElementById('audioSource').src = url;
document.getElementById('audioPlayback').load();
document.getElementById('result').innerHTML = "Speech ready to play.";
}
});
}
</script>
<!-- snippet-end:[Polly.HTML.browserExample.synthesize] -->
</body>
</html>
我尝试添加的下拉菜单如下,以 JSON 填充(但其他任何东西也可以):
<form>
<fieldset class="textBox" id="autoHeight">
<legend>Voice</legend>
<h2>Language/accent</h2>
<select name="drop_down" id="dropDownCars">
<option value="None" selected="Selected">Select type</option>
</select>
</fieldset>
</form>
谁能告诉我如何最好地集成下拉菜单,以便有可能选择 VoiceId? 非常感谢,借此机会祝您度过美好的一天,保持安全
米歇尔
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)