tflite_flutter_plugin
tflite_flutter_plugin copied to clipboard
Unhandled Exception: Bad state: failed precondition
@am15h Hi, I am trying to use https://teachablemachine.withgoogle.com/train/audio audio model with the package to count specific sound numbers in the audio from the microphone.
I wonder if it is possible to use a pre-trained audio model from https://teachablemachine.withgoogle.com/train/audio with the package or I need to create a custom one. I am trying to process real-time data from the microphone with the model, but I am getting this error. I am getting Uint8List from the microphone:
_audioStream = _recorder.audioStream.listen((data) {
print('data: $data');
var output = [];
_interpreter.run(data, output);
}
Getting this error when executing _interpreter.run function:
E/flutter (10616): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Bad state: failed precondition
E/flutter (10616): #0 checkState (package:quiver/check.dart:74:5)
E/flutter (10616): #1 Tensor.setTo (package:tflite_flutter/src/tensor.dart:146:5)
E/flutter (10616): #2 Interpreter.runForMultipleInputs (package:tflite_flutter/src/interpreter.dart:186:33)
E/flutter (10616): #3 Interpreter.run (package:tflite_flutter/src/interpreter.dart:157:5)
E/flutter (10616): #4 _AppState._initPlugin.<anonymous closure> (package:tf_test/main.dart:50:20)
E/flutter (10616): #5 _rootRunUnary (dart:async/zone.dart:1362:47)
E/flutter (10616): #6 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
E/flutter (10616): #7 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
E/flutter (10616): #8 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
E/flutter (10616): #9 _DelayedData.perform (dart:async/stream_impl.dart:591:14)
E/flutter (10616): #10 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706:11)
E/flutter (10616): #11 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:663:7)
E/flutter (10616): #12 _rootRun (dart:async/zone.dart:1346:47)
E/flutter (10616): #13 _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (10616): #14 _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (10616): #15 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
E/flutter (10616): #16 _rootRun (dart:async/zone.dart:1354:13)
E/flutter (10616): #17 _CustomZone.run (dart:async/zone.dart:1258:19)
E/flutter (10616): #18 _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
E/flutter (10616): #19 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
E/flutter (10616): #20 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
E/flutter (10616): #21 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
I am not sure what the problem is and I can't find any info on the topic. Any feedback is highly appreciated.
I am using this package version tflite_flutter: ^0.9.0 and sound_stream: ^0.3.0 to get Stream from the microphone. Here is a link to the whole test project code: https://gist.github.com/nazdream/70230ac86b55c9dfab088cdcad4e2503
Hi, did you later a solution or workaround to this? ... I have a slightly same project