有人知道为什么此文件记录在本地主机上而不是在github服务器上吗?

时间:2019-06-04 23:20:36

标签: javascript speech-recognition

应该在标签中显示红色的录制按钮,console.log正在录制

我没有输出,但可以在我的本地服务器上使用。请帮我 谢谢,github站点是https://codingoni.github.io/VoiceBot/。页面上只有一个按钮。 const btn = document.querySelector('.talk'); const content = document.querySelector('.content');

// Responses

const greetings = ['Hi there!','Whats Going on?','I am good how are you' ];


//Weather Integration http://weatherjs.com/

//Must Change Lectures to get correct keywords
let google = 'https://www.googleapis.com/customsearch/v1?key=INSERT_YOUR_API_KEY&cx=017576662512468239146:omuauf_lfve&q=lectures'
//

const SpeechRecognition =  window.SpeechRecognition || window.webkitSpeechRecognition;
const recognition = new SpeechRecognition();

recognition.onstart = ()=> {
    console.log ('voice is activated, you can talk to me');
};

recognition.onresult = (event)=> {
    const current = event.resultIndex;
    const transcript = event.results[current[0]].transcript;
    content.textContent = transcript;
    readOutLoud(transcript);
};

// add the listener to the button

btn.addEventListener('click',()=>{
    recognition.start();
});

function readOutLoud(message){
    const speech= new SpeechSynthesisUtterance();
    speach.text = 'I am not sure what that means'

    if (message.includes('Hi'||'Hey'||'How`s it going'||'What`s Happening')) {
       const finatlText = grettings[Math.floor(Math.random()*greetings.length)];
        speech.finalText;
    }else if (message.includes('How are you')) {
        const finatlText = grettings[2]
        speech.finalText;
    } else if  (message.includes('Todays Date'))        {

        const finatlText = new Date();
        speech.finalText;
    }
     //Weather Coming Soon
    speech.volume = 1;
    speech.rate= 1;
    speech.pitch = 2;


    window.speechSynthesis.speak(speech)
}

1 个答案:

答案 0 :(得分:0)

假设您的JavaScript文件名为app.js,则需要更改src标记的<script>属性以包括您的存储库名称。像这样:

<script src="/VoiceBot/app.js"></script>

那将使您康复。