console.log错误/下面的值刚刚被评估

时间:2019-06-02 03:30:38

标签: reactjs api react-native speech-recognition console.log

我正在制作一个语音识别程序,当我按下麦克风按钮时,出现错误并且无法录音。有什么办法可以解决?

它写为“ react”,此基础写为“ react-c l i”

语音识别错误存在问题“下面的值刚刚被评估。”。我用了铬。

我认为console.log()可能有问题

如何解决这个问题?请帮忙 如果您需要更多问题信息,请发表评论

state = {
show: false,
listening: false,
text: "Sorry, can't hear",
};
component Did Mount() {
const Recognition =
window.Speech Recognition || window.web kit Speech Recognition;
if (!Recognition) {
alert(
'Speech Recognition API is not supported in this browser, try chrome'
);
return;
}
this.recognition = new Recognition();
this.recognition.lang =  'k o-KR';
this.recognition.continuous = false;
this.recognition.interim Results = false;
this.recognition.max Alternatives = 1;
this.recognition.on result = event => {
  const text = event.results[0][0].transcript;
  console.log('transcript', text);
  this.set State({ text });
};
this.recognition.on speech end = () => {
console.log('stopped');
this.set State({ show: true });
};
this.recognition.on no match = () => {
console.log('no match');
this.set State({ text: "Sorry, can't hear" });
};
this.recognition.on start = () => {
  this.set State({listening: true});
};
this.recognition.on end = () => {
  console.log('end');
  this.set State({listening: false});
  this.end();
};
this.recognition.on error = event => {
console.log('error', event);
this.set State({
show: true,
text: event.error
});
};

“错误 SpeechRecognitionError {{已信任:true,错误:“不允许”,消息:“”,类型:“错误”,目标:SpeechRecognition,…} 气泡:错误 cancelBubble:否 可取消:false 组成:假 currentTarget:语音识别 连续:错误 语法:SpeechGrammarList {length:0} interimResults:否 lang:“ ko-KR” maxAlternatives:1 onaudioend:null onaudiostart:空 onend:ƒ() 错误:ƒ(t) onnomatch:ƒ() 结果:ƒ(t) onsoundend:null onsoundstart:null 对讲:ƒ() onspeechstart:空 onstart:ƒ() proto :语音识别 defaultPrevented:否 错误:“不允许” eventPhase:0 isTrusted:正确 信息: ”” 路径:[] returnValue:正确 srcElement:SpeechRecognition {语法:SpeechGrammarList,lang:“ ko-KR”,连续:false,临时结果:false,maxAlternatives:1,…} 目标:SpeechRecognition {语法:SpeechGrammarList,lang:“ ko-KR”,连续:false,临时结果:false,maxAlternatives:1,…} 时间戳:14645.344999998997 类型:“错误” 原始:SpeechRecognitionError”

0 个答案:

没有答案