Menu

Pre-load grammar file to be activated later?

Help
Kristoffer
2016-01-24
2016-01-24
  • Kristoffer

    Kristoffer - 2016-01-24

    Using PocketSphinx. I have two grammar files that due to their complexity cannot be loaded in the same jsgf file. Thus, I need to quickly swap between the two in runtime.

    I noticed that loading the files take quite some time. My idea is to start loading the inactive grammar file before I actually need it. This calls for another thread where the other grammar would be loaded, and then - if necessary - transferred to the main thread where it would be set.

    Can this be done with the API? E.g. Pre-load grammar and activate it through some call.

    grammar = asyncLoadJsgf();
    ...
    activateJsgf(grammar);

     
  • Nickolay V. Shmyrev

    ps_set_jsgf_file loads jsgf

    ps_set_search activates search after that.

    you can find examples in sources and in tutorial.

     
  • Kristoffer

    Kristoffer - 2016-01-24

    Yes, but if I call ps_set_jsgf_file I remove the current grammar, no? If that isn't the case, then I wonder if that API is thread safe. E.g. can I load grammrs in a separate thread and then call ps_set_search in the main thread?

     
    • Nickolay V. Shmyrev

      You can load all grammars on start and switch between them if needed. There is no need to use other threads.

       

Log in to post a comment.