Caldarie / flutter_tflite_audio

Audio classification Tflite package for flutter (iOS & Android). Can support Google Teachable Machine models
MIT License
64 stars 26 forks source link

iOS recognition only works if speak loudly/closely to mic #32

Open bobosette opened 2 years ago

bobosette commented 2 years ago

Hi @Caldarie . My app is in test mode right now. Someone reported that on iOS the recognition works only if people speak loud close to the microphone. Did you ever report an issue like that??

Thank you

Caldarie commented 2 years ago

Hi @bobosette

It seems iOS has been giving alot of issues lately :laughing:

For the earlier tflite_audio versions, this has been an issue. The reason being that the arrays have not been splicing properly. The later versions should of solved this problem but there could be a possibility that i have missed something.

Currently, i have been refractoring my code so that i could implement unit tests to find such issues. You can find my latest work on this branch here. Once i am done, i should be able to do an extensive test to find such bugs

bobosette commented 2 years ago

Ok...maybe i will try that branch

Caldarie commented 2 years ago

hi @bobosette

Can you provide your recording parameters for me?

I have finally refractored my code and can run unit tests yo check whether theres any problem with the splicing.

bobosette commented 2 years ago

Hi @Caldarie . This is my recording parameters:

` //model initialization TfliteAudio.loadModel( inputType: 'rawAudio', numThreads: 1, outputRawScores: true, isAsset: true, model: 'assets/cough_model.tflite', label: 'assets/cough_label.txt' );

// bring to foreground FlutterBackgroundService().setForegroundMode(true);

Stream<Map<dynamic, dynamic>>? result;

result = TfliteAudio.startAudioRecognition( sampleRate: 44100, //recordingLength: 44032, bufferSize: 11008, // to get 2-3 secs of analisys instead of 1 numOfInferences: 99999, detectionThreshold: 0.7, averageWindowDuration: 1500, ); `

bobosette commented 2 years ago

Hi @c. Do u have some news??

Caldarie commented 2 years ago

Hi

I have ran the tests as found here.

Good news is that all tests have passed and there should be no problems with the recording. I will post an update once i have finished refactoring android code.

bobosette commented 2 years ago

Oh perfect. Let me know when you release it.

Il giorno lun 14 mar 2022 alle ore 09:31 Michael Nguyen < @.***> ha scritto:

Hi

I have ran the tests as found here https://github.com/Caldarie/flutter_tflite_audio/blob/feature/inference_on_stored_audio/example/ios/RunnerTests/RecordingTest.swift .

Good news is that all tests have passed and there should be no problems with the recording. I will post an update once i have finished refactoring android code.

— Reply to this email directly, view it on GitHub https://github.com/Caldarie/flutter_tflite_audio/issues/32#issuecomment-1066507769, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADEWB4OT2N4LTOTIGXNYTQTU732OFANCNFSM5PUC5XVA . You are receiving this because you were mentioned.Message ID: @.***>

Caldarie commented 2 years ago

hi @bobosette

I have updated the package to 0.3.0. There are alot of bug fixes for both android and iOS. Let me know if you encounter any bugs

I also added asynchronous tasks for iOS, so you may want to try the background_task plugin again to see if it works.

As for the recognition issue which you mentioned, I do have an idea why this issue occurs. It seems that when the plugin splices the recording, it may splice the intended voice in half and hence becomes unrecognisable when fed into the model. To address this issue, I will introduce an overlapping feature for the next update.

bobosette commented 2 years ago

Perfect. I will try and I let you know

Il giorno ven 18 mar 2022 alle ore 06:30 Michael Nguyen < @.***> ha scritto:

hi @bobosette https://github.com/bobosette

I have updated the package to 0.3.0. There are alot of bug fixes for both android and iOS. Let me know if you encounter any bugs

As for the recognition issue which you mentioned, I do have an idea why this issue occurs. It seems that when the plugin splices the recording, it may splice the intended voice in half and hence becomes unrecognisable when fed into the model. To address this issue, I will introduce an overlapping feature for the next update.

— Reply to this email directly, view it on GitHub https://github.com/Caldarie/flutter_tflite_audio/issues/32#issuecomment-1072047776, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADEWB4ICKYRJIXIB6MDAYD3VAQIHVANCNFSM5PUC5XVA . You are receiving this because you were mentioned.Message ID: @.***>

bobosette commented 2 years ago

Hi @Caldarie. I was going to try your update, but when I run the Debug I have this error:

Error: CocoaPods's specs repository is too out-of-date to satisfy dependencies. To update the CocoaPods specs, run: pod repo update

Exception: Error running pod install

Then i do pod repo update, but same error.

bobosette commented 2 years ago

I forgot to tell you this: now with the latest update of flutter_background_service I was able to run flutter_tflite_audio also on background.

Caldarie commented 2 years ago

@bobosette

I have updated the plugin to work with the latest iOS packages, hence why you recieved the error.

To fix this issue:

flutter clean delete /ios/Pods delete /ios/Podfile.lock flutter pub get from inside ios folder: pod install Run

bobosette commented 2 years ago

Ok perfect thank you