error when load from external directory .. but if i load wav from asset dir is working
set is asset false..
and result like ...
Parameters: {audioDirectory=/data/user/0/com.example.hello/cache/file_picker/cat_1.wav, detectionThreshold=0.5, minimumTimeBetweenSamples=0, method=setFileRecognitionStream, averageWindowDuration=0, audioLength=0, sampleRate=44100, suppressionTime=0}
D/TfliteAudio(25258): AudioLength has been readjusted. Length: 8620
D/TfliteAudio(25258): Transpose Audio: false
D/TfliteAudio(25258): Check for permission. Request code: 1
D/TfliteAudio(25258): Loading audio file to buffer
D/TfliteAudio(25258): Audio file sucessfully loaded
D/TfliteAudio(25258): Extracting byte data from audio file
E/EventChannel#FileRecognitionStream(25258): Failed to open event stream
E/EventChannel#FileRecognitionStream(25258): java.lang.RuntimeException: Failed to load audio file:
E/EventChannel#FileRecognitionStream(25258): at flutter.tflite_audio.MediaDecoder.(MediaDecoder.java:36)
E/EventChannel#FileRecognitionStream(25258): at flutter.tflite_audio.TfliteAudioPlugin.extractRawData(TfliteAudioPlugin.java:531)
E/EventChannel#FileRecognitionStream(25258): at flutter.tflite_audio.TfliteAudioPlugin.loadAudioFile(TfliteAudioPlugin.java:520)
E/EventChannel#FileRecognitionStream(25258): at flutter.tflite_audio.TfliteAudioPlugin.checkPermissions(TfliteAudioPlugin.java:404)
E/EventChannel#FileRecognitionStream(25258): at flutter.tflite_audio.TfliteAudioPlugin.onListen(TfliteAudioPlugin.java:252)
E/EventChannel#FileRecognitionStream(25258): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onListen(EventChannel.java:218)
E/EventChannel#FileRecognitionStream(25258): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onMessage(EventChannel.java:197)
E/EventChannel#FileRecognitionStream(25258): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/EventChannel#FileRecognitionStream(25258): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
E/EventChannel#FileRecognitionStream(25258): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/EventChannel#FileRecognitionStream(25258): at android.os.Handler.handleCallback(Handler.java:883)
E/EventChannel#FileRecognitionStream(25258): at android.os.Handler.dispatchMessage(Handler.java:100)
E/EventChannel#FileRecognitionStream(25258): at android.os.Looper.loop(Looper.java:224)
E/EventChannel#FileRecognitionStream(25258): at android.app.ActivityThread.main(ActivityThread.java:7562)
E/EventChannel#FileRecognitionStream(25258): at java.lang.reflect.Method.invoke(Native Method)
E/EventChannel#FileRecognitionStream(25258): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
E/EventChannel#FileRecognitionStream(25258): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
E/EventChannel#FileRecognitionStream(25258): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.FileDescriptor android.content.res.AssetFileDescriptor.getFileDescriptor()' on a null object reference
E/EventChannel#FileRecognitionStream(25258): at flutter.tflite_audio.MediaDecoder.(MediaDecoder.java:34)
E/EventChannel#FileRecognitionStream(25258): ... 16 more
══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════
The following PlatformException was thrown while activating platform stream on channel
FileRecognitionStream:
PlatformException(error, Failed to load audio file: , null, null)
When the exception was thrown, this was the stack:
error when load from external directory .. but if i load wav from asset dir is working
set is asset false..
and result like ...
Parameters: {audioDirectory=/data/user/0/com.example.hello/cache/file_picker/cat_1.wav, detectionThreshold=0.5, minimumTimeBetweenSamples=0, method=setFileRecognitionStream, averageWindowDuration=0, audioLength=0, sampleRate=44100, suppressionTime=0} D/TfliteAudio(25258): AudioLength has been readjusted. Length: 8620 D/TfliteAudio(25258): Transpose Audio: false D/TfliteAudio(25258): Check for permission. Request code: 1 D/TfliteAudio(25258): Loading audio file to buffer D/TfliteAudio(25258): Audio file sucessfully loaded D/TfliteAudio(25258): Extracting byte data from audio file E/EventChannel#FileRecognitionStream(25258): Failed to open event stream E/EventChannel#FileRecognitionStream(25258): java.lang.RuntimeException: Failed to load audio file: E/EventChannel#FileRecognitionStream(25258): at flutter.tflite_audio.MediaDecoder.(MediaDecoder.java:36)
E/EventChannel#FileRecognitionStream(25258): at flutter.tflite_audio.TfliteAudioPlugin.extractRawData(TfliteAudioPlugin.java:531)
E/EventChannel#FileRecognitionStream(25258): at flutter.tflite_audio.TfliteAudioPlugin.loadAudioFile(TfliteAudioPlugin.java:520)
E/EventChannel#FileRecognitionStream(25258): at flutter.tflite_audio.TfliteAudioPlugin.checkPermissions(TfliteAudioPlugin.java:404)
E/EventChannel#FileRecognitionStream(25258): at flutter.tflite_audio.TfliteAudioPlugin.onListen(TfliteAudioPlugin.java:252)
E/EventChannel#FileRecognitionStream(25258): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onListen(EventChannel.java:218)
E/EventChannel#FileRecognitionStream(25258): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onMessage(EventChannel.java:197)
E/EventChannel#FileRecognitionStream(25258): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/EventChannel#FileRecognitionStream(25258): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
E/EventChannel#FileRecognitionStream(25258): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/EventChannel#FileRecognitionStream(25258): at android.os.Handler.handleCallback(Handler.java:883)
E/EventChannel#FileRecognitionStream(25258): at android.os.Handler.dispatchMessage(Handler.java:100)
E/EventChannel#FileRecognitionStream(25258): at android.os.Looper.loop(Looper.java:224)
E/EventChannel#FileRecognitionStream(25258): at android.app.ActivityThread.main(ActivityThread.java:7562)
E/EventChannel#FileRecognitionStream(25258): at java.lang.reflect.Method.invoke(Native Method)
E/EventChannel#FileRecognitionStream(25258): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
E/EventChannel#FileRecognitionStream(25258): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
E/EventChannel#FileRecognitionStream(25258): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.FileDescriptor android.content.res.AssetFileDescriptor.getFileDescriptor()' on a null object reference
E/EventChannel#FileRecognitionStream(25258): at flutter.tflite_audio.MediaDecoder.(MediaDecoder.java:34)
E/EventChannel#FileRecognitionStream(25258): ... 16 more
══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════ The following PlatformException was thrown while activating platform stream on channel FileRecognitionStream: PlatformException(error, Failed to load audio file: , null, null)
When the exception was thrown, this was the stack:
0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:315:18)