pbakondy / cordova-plugin-speechrecognition

:microphone: Cordova Plugin for Speech Recognition
MIT License
197 stars 117 forks source link

“Network error” on startListening() Android 6/7 #42

Open daveshirman opened 7 years ago

daveshirman commented 7 years ago

When I run the code below, as soon as the beep sounds to start recording the mic, I get "Network error":

I have no idea what's wrong here. I've:

Here's my basic code, nothing special here:

  setupSpeechRecognition() {
    this.speechRecognition.requestPermission().then(() => {
        this.speechRecognition.startListening().subscribe(
            (matches) => {
              // matches here...
            },
            (onerror) => {
              alert("Error: " + JSON.stringify(onerror));
            }
        );          
      },
      () => {}
    );      
  }

And here's my AndroidManifest.xml for kicks:

<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.ionic.starter" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <receiver android:name="cordova.plugins.Diagnostic$LocationProviderChangedReceiver">
            <intent-filter>
                <action android:name="android.location.PROVIDERS_CHANGED" />
            </intent-filter>
        </receiver>
        <receiver android:name="cordova.plugins.Diagnostic$NFCStateChangedReceiver">
            <intent-filter>
                <action android:name="android.nfc.action.ADAPTER_STATE_CHANGED" />
            </intent-filter>
        </receiver>
    </application>
    <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="25" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

Any ideas?

Thanks.

2f-concept commented 6 years ago

I Got the same issue with almost the same code but only with 1 phone (android 4.4.2) I don’t know where to search, if you found the solution, please share it. Thanks !

pacjin79 commented 6 years ago

Same problem here

2f-concept commented 6 years ago

I found the solution: samsung devices don't use google speech recognition api by default, when you configure the device to use google speech api, it works... Hope it can help someone !

leshik commented 5 years ago

@2f-concept could you please clarify on how to configure samsung devices to use google speech api, please?

2f-concept commented 5 years ago

Look in settings / general management / language and input / Then click Text to Speech