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.
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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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);
ps_set_jsgf_fileloads jsgfps_set_searchactivates search after that.you can find examples in sources and in tutorial.
Yes, but if I call
ps_set_jsgf_fileI 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 callps_set_searchin the main thread?You can load all grammars on start and switch between them if needed. There is no need to use other threads.