您如何获得输入的文本,在此示例中,可以自动说出您插入的名称?因此,在此示例代码中,有一些输入他们的名字,哈利·波特(Harry Potter(可以说,而不是文字,反应是口头的:"你好哈利·波特,你今天好吗?">
我在文本输入代码下方插入了一个示例音频代码作为特定点。如果可能的话,请使用视频
在40,41,42,43,173,205,204,235,283,339,44]},而不是下拉我对JavaScript确实很糟糕,所以请仅代码没有建议,因为我不知道它们的意思。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>eve_</title>
<link rel="icon" rel="preload" href="images/evecircle.png" />
<style>
#video {
margin-left:-10px;
margin-top:-10px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<style type="text/css">
body {
overflow:hidden;
}
</style>
<body onload="delayedAlert();">
<script>
function myText() {
var txt;
var person = prompt("What's your name?", "");
if (person == null || person == "") {
txt = "User cancelled the prompt.";
} else {
txt = "Hello " + person + "! How are you today?";
}
document.getElementById("demo").innerHTML = txt;
}
var timeoutID;
function delayedAlert() {
timeoutID = window.setTimeout(slowAlert, 14999);
then.getElementsByTagName('audiotwo')[0];
}
function slowAlert() {
var audio= document.getElementsByTagName('audio')[0];
const audio2 = document.getElementsByTagName('audio')[1];
const audio3 = document.getElementsByTagName('audio')[2];
audio.play();
var myvar1;alert('...Hello?')
audio2.play();
var myvar2;alert('Hello?');
audio3.play();
var sign = prompt("What's your sign?");
if (person == null || person == "") {
alert("Hello " + person + "! How are you today?");
}
}
</script>
<audio>
<source src="images/hellllloooo.wav" type="audio/wav" preload=true>
</audio>
<audio>
<source src="images/sorry.wav?.wav?.wav" type="audio/wav" preload=true>
</audio>
<audio>
<source src="images/sorry.wav?.wav?.wav" type="audio/wav" preload=true>
</audio>
<video autoplay="autoplay" preload="auto" id="video" src="images/secondnew.mp4" width="1300px" height="auto" style="position:absolute; z-index:-1;" >
Video not supported.
</video>
</body>
</html>
//////////////////////
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
JavaScript
<script src="https://code.responsivevoice.org/responsivevoice.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<textarea id="text" cols="45" rows="3">Hello world</textarea>
<select id="voiceselection"></select>
<input
onclick="responsiveVoice.speak($('#text').val(),$('#voiceselection').val());"
type="button"
value="Play"
/>
<script>
//Populate voice selection dropdown
var voicelist = responsiveVoice.getVoices();
var vselect = $("#voiceselection");
$.each(voicelist, function() {
vselect.append($("<option />").val(this.name).text(this.name));
});
</script>
<script src="https://code.responsivevoice.org/responsivevoice.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<textarea id="text" cols="45" rows="3">What's your name?</textarea>
<select id="voiceselection"></select>
<input
onclick="responsiveVoice.speak($('#text').val(),$('#voiceselection').val());"
/>
<script>
//Populate voice selection dropdown
var voicelist = responsiveVoice.getVoices();
var vselect = $("#voiceselection");
$.each(voicelist, function() {
vselect.append($("<option />").val(this.name).text(this.name));
});
</script>
<body>
</body>
</html>
这样:
const name = prompt('What is your name?')
const sentence = 'Hello ' + name + '! How are you today?';
responsiveVoice.speak(sentence);
<script src="https://code.responsivevoice.org/responsivevoice.js"></script>