如何进行语音提示响应

时间:2018-04-01 04:17:51

标签: javascript api response prompt voice

你怎么能得到输入的文字,在这个例子中是一个名字,自动说出你插入的名字?因此,在这个示例代码中,让一些人输入他们的名字,哈利波特可以说,而不是文本,回应将是口头的,“你好哈利波特,你今天好吗?”

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

{name:“US English Female”,flag:“us”,性别:“f”,voiceIDs:[39, 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>

1 个答案:

答案 0 :(得分:2)

像这样:

public static void main(String[] args) {

    Scanner in = new Scanner(System.in);
    System.out.print("Enter an integer between 100-999: ");
    int integer = in.nextInt();
    int reverse = 0;

    if (integer >= 100 && integer <= 999) {
        while(integer != 0)
        {
            reverse = reverse * 10;
            reverse = reverse + integer%10;
            integer = integer/10;
        }

        System.out.println("Reverse of the number is " + reverse);
    } else {
        System.out.print("Your number is not in the correct range, good bye");
    }

}
const name = prompt('What is your name?')
const sentence = 'Hello ' + name + '! How are you today?';
responsiveVoice.speak(sentence);