Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to init Snowboy, required bundled file 'common.res' missing #2

Closed
8088boy opened this issue Jun 25, 2023 · 2 comments
Closed

Comments

@8088boy
Copy link

8088boy commented Jun 25, 2023

Hi there,

Thanks for making this package, but I haven't get it working till now, always got 'common.res' missing problem. I downloaded the file from https://github.com/Kitt-AI/snowboy/blob/master/resources/common.res and load it in runtime as well.

What I did:

  1. install all packages
  2. put the pmdl file , common.res , ding.wav in the root's assets folder and declared in pubspec.yml
flutter:
  assets:
     - assets/yoyo.pmdl
     - assets/common.res 
     - assets/ding.wav

The code is learned from the example in https://pub.dev/packages/flutter_snowboy

...

    final directory = await getApplicationDocumentsDirectory();
    final modelPath = "${directory.path}/yoyo.pmdl";
    final commonResPath = "${directory.path}/common.res";
    
    final bytes = await rootBundle.load("assets/yoyo.pmdl");
    final modelData = bytes.buffer.asUint8List();
    await File(modelPath).writeAsBytes(modelData);
    debugPrint('>>> modelPath: $modelPath'); 

    final commonResBytes = await rootBundle.load("assets/common.res");
    final commonResData = commonResBytes.buffer.asUint8List();
    await File(commonResPath).writeAsBytes(commonResData);
    debugPrint('>>> commonResPath: $commonResPath');

    detector = Snowboy();
    await detector.prepare(modelPath); // working, otherwise, it will show the model missing
    detector.hotwordHandler = hotwordHandler;
    await configureAudioSession();
...

The console display:

flutter: >>> modelPath: /var/mobile/Containers/Data/Application/46445C07-C970-468C-B548-D63578DC4BC3/Documents/yoyo.pmdl
flutter: >>> commonResPath: /var/mobile/Containers/Data/Application/46445C07-C970-468C-B548-D63578DC4BC3/Documents/common.res
Unable to init Snowboy, required bundled file 'common.res' missing

I found the similar discussion here: Kitt-AI/snowboy#309
But I don't find a way to pass the common.res path in this lib.

@8088boy
Copy link
Author

8088boy commented Jun 25, 2023

@8088boy
Copy link
Author

8088boy commented Jun 26, 2023

It's solved by adding the common.res into the bundle file of Xcode.

image
image

@8088boy 8088boy closed this as completed Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant