无法在cordova上初始化SpeechRecognition

时间:2018-10-16 19:56:22

标签: kendo-ui phonegap-plugins

我有一个用Keno UI(Telerik)编写的应用程序。我正在使用build.phonegap.com通过cordova和Kendo为我的应用程序构建运行时。我一直坚持让语音识别插件进行初始化。我确定这很愚蠢,但我不确定它是什么。  下面是我的config.xml文件的副本:

<?xml version='1.0' encoding='utf-8'?>
<widget id="ca.xyz.mmb" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>mmb</name>
<description>
    Integrated Mobile Billing for XYZ Customers
</description>
<author email="support@xyz.ca" href="http://xyz.ca">
    Go Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-compat" spec="^1.2.0" />
<plugin name="cordova-plugin-file" spec="^4.3.3" />
<plugin name="cordova-plugin-speechrecognition" spec="1.2.0" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
    <allow-intent href="market:*" />
</platform>
<platform name="ios">
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
</platform>
<engine name="ios" spec="^4.3.1" />
</widget>

下面是该版本相关部分的副本:

Build Date: 2018-10-16 05:38:36 +0000
--------------------------------------------------------------------------------
PLUGIN OUTPUT
--------------------------------------------------------------------------------
Fetching plugin "cordova-plugin-compat@^1.2.0" via npm
Installing "cordova-plugin-compat" at "1.2.0" for android
Fetching plugin "cordova-plugin-file@^4.3.3" via npm
Installing "cordova-plugin-file" at "4.3.3" for android
Plugin dependency "cordova-plugin-compat@1.2.0" already fetched, using that version.
Dependent plugin "cordova-plugin-compat" already installed on android.
The Android Persistent storage location now defaults to "Internal". 
Please check this plugin's README to see if your application needs any changes in its config.xml.

If this is a new application no changes are required.

If this is an update to an existing application that did not specify an "AndroidPersistentFileLocation" you may need to add:

  "<preference name="AndroidPersistentFileLocation" value="Compatibility" />"

to config.xml in order for the application to find previously stored files.
Fetching plugin "cordova-plugin-speechrecognition@1.2.0" via npm
Installing "cordova-plugin-speechrecognition" at "1.1.2" for android
--------------------------------------------------------------------------------
PROJECT PROPERTIES

下面是该程序的初始化代码。

(function () {
var bootstrap = function () {
    $(function () {
        alert("running bootstrap");
        app.mobileApp = new kendo.mobile.Application(document.body, {

            transition: 'slide',
            skin: 'flat',
            initial: 'components/home/view.html',
            statusBarStyle: 'black-translucent',
            layout: 'main'
        });
    alert("speech init ");        //this is the last alert that pops up
    window.plugins.speechRecognition.isRecognitionAvailable(
            function(result) { 
                useSpeech = result ; alert("speech");
            }, 
            function(err) { 
                useSpeech = false; alert(err);
            }
        );
        alert("done speech init");
    });
};
bootstrap();

我尝试运行的地方isRecognitionAvailable是失败的地方。我不知道为什么。我试过为window.plugins设置警报,只是为了看看它说了什么,但总是返回未定义状态。在Google上搜索表明这是正常现象,因此对我没有太大帮助。

0 个答案:

没有答案