Javascript 如何做一个语音提示回应

Javascript 如何做一个语音提示回应,javascript,api,response,prompt,voice,Javascript,Api,Response,Prompt,Voice,您如何获得输入的文本(在本例中为名称),以自动说出您插入的名称?所以在这个示例代码中,让一些人输入他们的名字,哈利波特让我们说,而不是文本,回答是口头的,“你好,哈利波特,你今天好吗?” 我在文本输入代码下面插入了一个示例音频代码作为特定点。 如果可能,请使用视频 {姓名:“美国-英国女性”,国旗:“美国”,性别:“f”,语音:[39, 40,41,42,4317320524235339,44]}而不是下拉列表 我真的很讨厌javascript,所以请只编写代码,不要建议,因为我不知道它们的意思

您如何获得输入的文本(在本例中为名称),以自动说出您插入的名称?所以在这个示例代码中,让一些人输入他们的名字,哈利波特让我们说,而不是文本,回答是口头的,“你好,哈利波特,你今天好吗?”

我在文本输入代码下面插入了一个示例音频代码作为特定点。 如果可能,请使用视频

{姓名:“美国-英国女性”,国旗:“美国”,性别:“f”,语音:[39, 40,41,42,4317320524235339,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>

夏娃_
#录像带{
左边距:-10px;
利润上限:-10px;
}
身体{
溢出:隐藏;
}
函数myText(){
var-txt;
var person=prompt(“您叫什么名字?”,”);
如果(person==null | | person==“”){
txt=“用户取消了提示。”;
}否则{
txt=“你好”+person+“!你今天好吗?”;
}
document.getElementById(“demo”).innerHTML=txt;
}
var-timeoutID;
函数delayedAlert(){
timeoutID=window.setTimeout(slowAlert,14999);
然后.getElementsByTagName('audiotwo')[0];
}
函数slowAlert(){
var audio=document.getElementsByTagName('audio')[0];
const audio2=document.getElementsByTagName('audio')[1];
const audio3=document.getElementsByTagName('audio')[2];
音频播放();
var myvar1;警报(“…您好?”)
音频2.播放();
var myvar2;警报('Hello?');
3.播放();
var sign=prompt(“你的符号是什么?”);
如果(person==null | | person==“”){
警惕(“你好”+人+“!你今天好吗?”);
}
}
不支持视频。
//////////////////////
无标题文件
JavaScript
你好,世界
//填充语音选择下拉列表
var voicelist=responsiveVoice.getVoices();
var vselect=$(“#语音选择”);
$.each(语音列表,函数(){
vselect.append($(“”).val(this.name).text(this.name));
});
你叫什么名字?
//填充语音选择下拉列表
var voicelist=responsiveVoice.getVoices();
var vselect=$(“#语音选择”);
$.each(语音列表,函数(){
vselect.append($(“”).val(this.name).text(this.name));
});
像这样:

const name=prompt('你叫什么名字?')
常量句子='你好'+名字+'!你今天好吗;
回应的声音。说话(句子)

是的,但是我如何将这是一个订单插入到当前代码中?我不知道你对其余代码做了什么-如果你想知道如何提示某人的名字,然后使用库说出,用上面的代码片段替换整个HTML。在两次提醒之后,我将在那里放置提示,或者至少我试着在你的问题中看不到关于“我有什么事吗?”的任何东西(因为某种原因,似乎有两个HTML文档+脚本组合成一个?)。但是,如果您想在“Is some here with me?”警报之后运行该提示符并说出代码,那么只需在警报之后将my JS粘贴到上方,并将库添加到HTML中即可。