我正试图在我的网站上添加印地语“男性”口音,该网站目前具有“美国男性”口音。我使用了一个名为activevoice.org的网站,该网站为我提供了一个唯一的链接,需要在body标签关闭之前添加该链接,因此我按照提示进行操作。它没有用,所以我输入了另一个脚本src,我看到有人在他们使用activevoice.org时将其放在他们的网站上,这在控制台中产生了4件事。他们中的一个说语音支持已经准备好,另一个说响应式语音r1(所以我相信我要走了。)但是,一个是冗长的,最后一个是我放置第一个脚本时出现的错误。 src。我该如何解决?顺便说一句,我在一个文件中使用我的HTML和JS。有人可以回答吗?
const btn = document.querySelector('.talk');
const content = document.querySelector('.content');
const greetings = [
'If you are good im good too.',
'Im doin alright',
'doing well.'
];
const weather = [
'Ask the weatherman!',
'I recommend checking your phone or the news '
];
const name = [
'My name is techwaala',
'its techwaala, because I love to code!'
];
const hello = [
'Why hello! How are you doing today?',
'Hey there How are you?'
];
const hru = [
'thats great!',
'Im so sorry to hear that',
'Feel better soon!'
];
const SpeechRecognition =
window.SpeechRecognition || window.webkitSpeechRecognition;
const recognition = new SpeechRecognition();
recognition.onstart = function() {
console.log('voice is activated speak into the mic');
};
recognition.onresult = function(event) {
const current = event.resultIndex;
const transcript = event.results[current][0].transcript;
content.textContent = transcript;
readOutLoud(transcript);
}
btn.addEventListener('click', () => {
recognition.start();
});
function readOutLoud(message) {
const speech = new SpeechSynthesisUtterance();
speech.text = 'I dont know what you said';
if(message.includes('how are you')) {
const finalText =
greetings[Math.floor(Math.random() * greetings.length)];
speech.text = finalText;
}
if(['hey', 'hi', 'hello', 'hi there', 'hey there', 'hi techwala', 'hey techwala','hello techwala']
.some(word => message.includes(word))) {
const finalText = hello[Math.floor(Math.random() * hello.length)];
speech.text = finalText;
}
if(['whats your name', 'your name']
.some(word => message.includes(word))) {
const finalText = name[Math.floor(Math.random() * name.length)];
speech.text = finalText;
}
if(['how\'s the weather', 'what\'s the weather like', 'is it sunny', 'is it raining', 'is it cloudy', 'is it snowing']
.some(word => message.includes(word))) {
const finalText = weather[Math.floor(Math.random() * weather.length)];
speech.text = finalText;
}
speech.volume = 1;
speech.rate = 1;
speech.pitch = 1;
window.speechSynthesis.speak(speech);
}
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<button class="talk">Talk</button>
<h3 class="content"></h3>
<script src="https://code.responsivevoice.org/responsivevoice.js"></script>
<script src="//code.responsivevoice.org/responsivevoice.js?key=NNni6L33"></script>
</body>
</html>