编辑、更新
看到我的主要目标是首先让用户通过语音(语音转文本)请求特定的(书名),然后打开书大声朗读(文本转语音),最后一步是将这本书打印到盲文,我的难点是我没有找到以pdf格式打开这本书的方法,所以我只是把他留作文本区域,而且我不知道如何使用此代码https://gist.github.com/meh/141520将文本转换为盲文字母
<小时/>我的目标是调用不同的变量时打开不同的页面 但代码没有响应,只有一个变量打开一页
if (speechresult ) {
//here I added speechrecognizer.stop for the commands to not get interrupted
speechRecognizer.stop();
var yourValue = 'Book 1';
window.open("http://localhost/introductiontonetworking.html");
responsiveVoice.speak(bookstart, "UK English Female", {
//The pitch property of the SpeechSynthesisUtterance interface gets and sets the pitch at which the utterance will be spoken at. by default 1
pitch: 1
}, {
//rate by default 1
rate: 1
});
}
else if (speechresult == book2) {
speechRecognizer.stop();
var yourValue = 'Book 2';
window.open("http://localhost/ethicalhacking.html");
responsiveVoice.speak(bookstart, "UK English Female", {
pitch: 1
}, {
rate: 1
});
}
我计划使用多本书,所以当说 = book1 打开第一本书而 book2 = 打开第二本书时,依此类推?我的代码有什么问题
最佳答案
您可以尝试关联数组来存储书名和链接
link_arr['book1']='linkforbook1'; link_arr['book2']='linkforbook2'; 。 。 .
通过以下方式获取相应书籍的链接
link=link_arr[bookVal];
关于javascript - 使用多个变量打开不同的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47113870/