我有一些我缺少的电话空白。当我尝试下面的代码,在我的Iphone(通过PhoneGap桌面为Mac),它只是没有做任何事情....
以下是我尝试使用此处的STT插件的代码:
https://github.com/macdonst/SpeechRecognitionPlugin
在主config.xml中:
<gap:plugin name="org.apache.cordova.speech.speechrecognition" />
<plugin name="org.apache.cordova.speech.speechrecognition">
<param name="apiKey" value="5eae11XXXXXXXXX9048a4ce836d" />
</plugin>
在我从代码中找到的代码中(因此它应该可以工作......):
<!DOCTYPE html>
<html>
<head>
<title>Capture Photo</title>
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1"/>
<script type="text/javascript" charset="utf-8" src="js/phonegap.js"></script>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
</head>
<body>
<br/><br/><br/><br/>
<textarea id="textarea" rows=10 cols=80></textarea>
<button id="button" onclick="toggleStartStop()"></button>
<script type="text/javascript">
var recognizing;
var recognition = new SpeechRecognition();
recognition.continuous = true;
reset();
recognition.onend = reset;
recognition.onresult = function (event) {
for (var i = resultIndex; i < event.results.length; ++i) {
if (event.results.final) {
textarea.value += event.results[i][0].transcript;
}
}
}
function reset() {
recognizing = false;
button.innerHTML = "Click to Speak";
}
function toggleStartStop() {
if (recognizing) {
recognition.stop();
reset();
} else {
recognition.start();
recognizing = true;
button.innerHTML = "Click to Stop";
}
}
</script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();</script>
</body>
</html>
配置中有什么东西我做错了吗?
附带问题:它在github页面中说:
cordova plugin add https://github.com/macdonst/SpeechRecognitionPlugin
但它不起作用,所以我打字:
phonegap plugin add https://github.com/macdonst/SpeechRecognitionPlugin
“cordova”与“phonegap”有什么区别?