当我在生产服务器上部署此代码并在本地服务器上正常运行时,为什么会出现错误?

时间:2020-01-01 11:30:00

标签: javascript django ibm-cloud production-environment webkitspeechrecognition

我想从用户那里获取使用白话语言的语音输入。此代码已在Django Web应用程序上实现,当Django服务器在本地工作时,它可以正常工作,但是当我在云上部署它时,它显示错误:

不允许。

当它在本地计算机上工作时,为什么将其部署在云上时却不工作?

错误:

enter image description here

var message = document.querySelector('#message');

var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition;
var SpeechGrammarList = SpeechGrammarList || webkitSpeechGrammarList;

var grammar = '#JSGF V1.0;'

var recognition = new SpeechRecognition();
var speechRecognitionList = new SpeechGrammarList();
speechRecognitionList.addFromString(grammar, 1);
recognition.grammars = speechRecognitionList;
recognition.lang = 'bn';
recognition.interimResults = false;

recognition.onspeechend = function() {
  recognition.stop();
};

recognition.onerror = function(event) {
  message.textContent = 'Error : ' + event.error;
}

document.querySelector('#btnGiveCommand').addEventListener('click', function() {
  recognition.start();

});

recognition.onresult = function(event) {
  var last = event.results.length - 1;
  var command = event.results[last][0].transcript; // Pass this variable's value at the backend
  if (command != null) {
    document.getElementById('user_text').value = command;
    //user_text.style.display = "block";
    //submit.style.display = "block";
    document.getElementById("userText").submit();
  }
};
<form action="./user_input" ,method="get" id="userText">
  <input type="text" id='user_text' name="user_data">
</form>

<button id='btnGiveCommand'>Press here to speak</button>
<br><br>
<span id='message'></span>
<br><br>

0 个答案:

没有答案