pbakondy / cordova-plugin-speechrecognition

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

startListening don't work on iOS 10 #17

Closed LUCIANOSOLER closed 7 years ago

LUCIANOSOLER commented 7 years ago

I implemented functions in this order and works ok on Android, but startListening doesn't works on iOS 10.

Functions Avaliable - (works on android and iOS) HasPermition - (works on android and iOS) RequestPermition - (works on android and iOS)

But startListening - (works on android, but not works on iOS 10)

I already given permission on NSMicrophoneUsageDescription and NSSpeechRecognitionUsageDescription with its string value in info.plist

I call permissions before i call startListening, but doesn´t works on iOS.

I am with: Cordova CLI: 6.5.0 Ionic Framework Version: 2.0.1 Ionic CLI Version: 2.1.18 Ionic App Lib Version: 2.1.9 Ionic App Scripts Version: 1.0.0 ios-deploy version: 1.9.1 ios-sim version: 5.0.13 OS: macOS Sierra Node Version: v6.9.2 Xcode version: Xcode 8.2.1 Build version 8C1002

The erros that appears to me is --> error domain=kAFAssistantErrorDomain, same as others issues.

Can you have some idea why this is happen?

pbakondy commented 7 years ago

sadly Apple provides poor support for Speech API. Just look at the official forum: https://forums.developer.apple.com/search.jspa?q=kAFAssistantErrorDomain

I really not able to tell you what could be the problem. It works on my device and I can not reproduce this error.

LUCIANOSOLER commented 7 years ago

I understand, can you send me your project? maybe some configuration of your project can be different and work here.

AugusDogus commented 7 years ago

I'm also receiving Error Domain=kAFAssistantErrorDomain Code=1 "(null)". In some circumstances recognition works, but only after idling for several minutes. More in this picture.

Edit: This was after calling voiceSearch a second time. See my code below.

voiceSearch() {

    SpeechRecognition.isRecognitionAvailable()

      .then((available: boolean) => {

        SpeechRecognition.requestPermission()

          .then(

            () => {

              SpeechRecognition.startListening()

              .subscribe(

                (matches: Array<string>) => {

                  this.query = matches[0];

                  this.getResponse();

                  console.log(matches[0]);

                },

                (onerror) => console.log('error:', onerror)

              );

              console.log('Granted');

            },

            () => console.log('Denied')

          )

      })
  }
AugusDogus commented 7 years ago

I should mention the above also works flawlessly on Android.

ghost commented 7 years ago

Same error here, with your plugin and with this one: https://github.com/macdonst/SpeechRecognitionPlugin tested on iOS 10 and both do not work with same error. On android, no problem.

pbakondy commented 7 years ago

Please check last release

AugusDogus commented 7 years ago

How can we update from Ionic?

edit: npm install ionic-native@latest --save --save-exact

AugusDogus commented 7 years ago

I am still experiencing issues with using the code that I provided above. Here are the steps I took:

  1. Update ionic-native
  2. Make a button that is bound to the function voiceSearch that is listed in a previous comment.
  3. Tap button and say "What is the time". a. Wait. b. No response. Nothing logged in console.
  4. Tap button and say "What is the time". a. Wait b. Error logged in the console.
  5. Tap button and say "What is the time". a. Wait b. Returns identified words in the console.

edit: Forgot to include the log. Can you please provide a function similar to mine that works on both ios and android? Currently the function voiceSearch that I listed above works fine on android. If it's impossible to write a function that works for both platforms, can you provide a snippet that works for ios only?

Thank you!

ghost commented 7 years ago

@aurothic, How long did you wait? Seems that needs to wait for about 1 minute for a response back, can you try?

pbakondy commented 7 years ago

@aurothic you don't need to update ionic-native package. You have to update the cordova plugin itself.

cordova plugin rm cordova-plugin-speechrecognition
cordova plugin add cordova-plugin-speechrecognition
LUCIANOSOLER commented 7 years ago

Thanks @pbakondy now works ...

pbakondy commented 7 years ago

Great! Can we close the issue?

AugusDogus commented 7 years ago

This worked for me as well. However, there still is the matter of waiting for a 1 minute timeout before displaying the results. Android detects when the user stops talking, is there any such way to do this on IOS?

LUCIANOSOLER commented 7 years ago

For ios use stopListening method.

AugusDogus commented 7 years ago

Yes, but when should I call it? Currently I have a button that starts the listening process. This works very well on android, does it not carry over to ios?

LUCIANOSOLER commented 7 years ago

You need use plugin "Platform" to knows if you are on android or ios. https://ionicframework.com/docs/v2/api/platform/Platform/

On my app I put timer when i call startListening for ios ( 5 seconds ) when time over, the program calls stopListening

AugusDogus commented 7 years ago

Seems like bad practice. Perhaps this plugin could be used with DB Meter.

atul-athawale commented 5 years ago

With Ionic 4 not working on IOS. Getting below error. TypeError: Object(WEBPACK_IMPORTED_MODULE_1ionic_native_core["cordova"]) is not a function. (In 'Object(__WEBPACK_IMPORTED_MODULE_1ionic_native_core["cordova"])(this, "isRecognitionAvailable", {}, arguments)', 'Object(WEBPACK_IMPORTED_MODULE_1ionic_native_core["cordova"])' is an instance of Object)