capacitor-community / speech-recognition

MIT License
79 stars 42 forks source link

Android : Last word is not being captured #58

Closed aumbit-developer closed 1 year ago

aumbit-developer commented 1 year ago

Describe the bug

When testing on an Android device with partial results the last word I utter is always missed. E.g. When I speak "This is a test" ==> I get "This is a ". However when I say "This is a test stop", then I get "This is a test". If I set prompt to true, then the complete sentence is shown on the Google prompt. But w/o prompt the last word gets cut. Is anyone else facing this issue?

To Reproduce

Steps to reproduce the behavior:

  1. Start the "Speak" option (Prompt = false)
  2. Say "This is a test"
  3. Output => "This is a "

Expected behavior

App returns the complete set of words heard when prompt is set to false, similar to as seen on Google prompt

Screenshots

Adding Screenshots wont help as you cannot see what I am speaking ;)

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

-

Maculapse commented 1 year ago

Experiencing the same problem...

Konijima commented 1 year ago

Experiencing the same problem on a Pixel 6a using

"@capacitor-community/speech-recognition": "^4.0.0",
"@capacitor/android": "^4.7.3",
"@capacitor/angular": "^2.0.3",
jesusjimenez1995 commented 1 year ago

Hello, I am getting the same error that has been mentioned earlier.

Is there any update on this matter?

Thank you very much.

abclangs commented 1 year ago

Could you please send me your code in order to help you

jesusjimenez1995 commented 1 year ago

Hello, of course

This is the package.json

"dependencies": { "@angular/common": "^15.0.0", "@angular/core": "^15.0.0", "@angular/forms": "^15.0.0", "@angular/platform-browser": "^15.0.0", "@angular/platform-browser-dynamic": "^15.0.0", "@angular/router": "^15.0.0", "@awesome-cordova-plugins/nfc": "^6.3.0", "@capacitor-community/barcode-scanner": "^3.0.3", "@capacitor-community/speech-recognition": "^4.0.0", "@capacitor-community/text-to-speech": "^2.1.0", "@capacitor/android": "4.6.3", "@capacitor/app": "4.1.1", "@capacitor/core": "4.6.3", "@capacitor/haptics": "4.1.0", "@capacitor/keyboard": "4.1.1", "@capacitor/status-bar": "4.1.1", "@ionic/angular": "^6.1.9", "axios": "^1.3.4", "ionicons": "^6.0.3", "phonegap-nfc": "file:my-phonegap-nfc-0.0.1.tgz", "rxjs": "~7.5.0", "tslib": "^2.3.0", "zone.js": "~0.11.4" }

And this is my function where I use de speech-recognition:

async startRecognition(){ const { available } = await SpeechRecognition.available(); if(available){ SpeechRecognition.start({ popup: false, partialResults: true, language: 'es-ES', maxResults: 5, }); SpeechRecognition.addListener('partialResults',(partialResults: any) =>{ this.searchText = partialResults.matches; this.changeDetectorRef.detectChanges(); }); } }

Thanks for the help, it's appreciated.

aumbit-developer commented 1 year ago

This is snippet of my code which is making the call. `

if(!this.permissionAvailable){
  console.log('Awaiting Permission check');
  this.permissionAvailable = await this.checkPermissions();
  console.log('Permission updated : ', this.permissionAvailable);
}

if(this.permissionAvailable){
  this.listening = true;
 SpeechRecognition.start({
    language: "en-US",
    //maxResults: 5,
    prompt: "Say something",
    partialResults: true,
    popup: false,
  });

  // listen to partial results
  SpeechRecognition.addListener("partialResults", (data: any) => {
    console.log("partialResults was fired", data.matches);
   if(data.matches && data.matches.length > 0){
    this.content = data.matches[0];
    this.changeDetectRef.detectChanges();
   }
    console.log(this.content);
  });
}
else{
  console.log('No speech permissions available');
  this.content = 'No speech permissions available';
  this.changeDetectRef.detectChanges();
}

`

Additionally here is an overview of the dependencies in package.json { "dependencies": { "@angular/common": "^15.0.0", "@angular/core": "^15.0.0", "@angular/forms": "^15.0.0", "@angular/platform-browser": "^15.0.0", "@angular/platform-browser-dynamic": "^15.0.0", "@angular/router": "^15.0.0", "@capacitor-community/speech-recognition": "^4.0.0", "@capacitor/android": "4.6.3", "@capacitor/app": "4.1.1", "@capacitor/core": "4.6.3", "@capacitor/haptics": "4.1.0", "@capacitor/keyboard": "4.1.1", "@capacitor/status-bar": "4.1.1", "@ionic/angular": "^6.1.9", "ionicons": "^6.0.3", "rxjs": "~7.5.0", "tslib": "^2.3.0", "zone.js": "~0.11.4" }, "devDependencies": { "@angular-devkit/build-angular": "^15.0.0", "@angular-eslint/builder": "^14.0.0", "@angular-eslint/eslint-plugin": "^14.0.0", "@angular-eslint/eslint-plugin-template": "^14.0.0", "@angular-eslint/template-parser": "^14.0.0", "@angular/cli": "^15.0.0", "@angular/compiler": "^15.0.0", "@angular/compiler-cli": "^15.0.0", "@angular/language-service": "^15.0.0", "@capacitor/cli": "4.6.3", "@ionic/angular-toolkit": "^6.0.0", "@types/jasmine": "~4.0.0", "@types/node": "^12.11.1", "@typescript-eslint/eslint-plugin": "5.3.0", "@typescript-eslint/parser": "5.3.0", "eslint": "^7.6.0", "eslint-plugin-import": "2.22.1", "eslint-plugin-jsdoc": "30.7.6", "eslint-plugin-prefer-arrow": "1.2.2", "jasmine-core": "~4.3.0", "jasmine-spec-reporter": "~5.0.0", "karma": "~6.4.0", "karma-chrome-launcher": "~3.1.0", "karma-coverage": "~2.2.0", "karma-coverage-istanbul-reporter": "~3.0.2", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.0.0", "ts-node": "~8.3.0", "typescript": "~4.8.4" }, }

@luisgutie : Thanks for looking into this.. Does this information help or do you need any more information?

aumbit-developer commented 1 year ago

@luisgutie Any luck finding something?

abclangs commented 1 year ago

I have been busy. That's why I haven't been able to test your code. This issue seems to have been closed. Did you find a fix? Please let me know

aumbit-developer commented 11 months ago

@luisgutie @jcesarmobile I was able to test this yesterday and with the new changes, I am able to get the last word (at least on Android 12 device which I was testing).