C++/SAPI LoadCmdFromFile question
I'm sorry, I neglected to mention that I'm developing on Windows XP to be run on XP, so it isn't a problem with it not supporting unicode, as far as I know. My project is very simple so far. It just creates a window and attempts to initialize speech recognition, but it always gets hung on loading the grammar file. If you would like, or rather, wouldn't mind, I could post the project or email it to you so you can see exactly what I have.
Again, I really apreciate you taking your time for this.
Hi there, I'm not sure if you have any experience with this or not, but I figure it's worth a shot. I'm using VS.Net, writing in C++. I am writing a program to control a music playlist by voice commands and I need to load the grammar from an external file that will periodically be updated. The SDK shows that LoadCmdFromFile is what I need, so I call the command and I always receive E_INVALIDARG error when the function returns. According to the documentation, that means "...FileName is invalid or bad. Alternatively, Options is neither SPLO_STATIC nor SPLO_DYNAMIC."
I call it like so:
I have mygrammar.xml in the project directory, and the debug directory, so I know it is there, and I've also tried sending the function the entire path, but it always returns the same.
Do you have any ideas on what might be causing this?
ISpRecoGrammar::LoadCmdFromFile loads a SAPI 5 command and control grammar from a file. The file can either be a compiled or uncompiled grammar file. To modify the rules of the grammar after it has been loaded, specify SPLO_DYNAMIC for the Options parameter, otherwise specify the SPLO_STATIC flag.
const WCHAR *pszFileName,
[in, string] The name of the file containing the command and control grammar. SAPI 5 support loading of compiled and static grammars using URL.
[in] Flag of type SPLOADOPTIONS indicating whether the grammar will be modified dynamically.
S_OK Function completed successfully.
E_INVALIDARG pszFileName is invalid or bad. Alternatively, Options is neither SPLO_STATIC nor SPLO_DYNAMIC.
FAILED(hr) Appropriate error message.
<ID NAME="VID_Command" VAL="1"/>
<RULE ID="VID_Command" TOPLEVEL="ACTIVE">
Well, I certainly appreciate your time in looking over this.
Michael, Thank you for your question.
This looks like a very interesting application, and one that might be of interest to blind and visually impaired computer users (this is an area of interest for me).
My guess is that the problem is in the statement
You are using a wide character string literal. But perhaps you are running under Windows 98 or some such, where the file system does not use Unicode.
Let me know if this is not the problem, and I'll think about it some more.
Michael, Actually I am interested in your project, as I have used some of SAPI in the past.
It would be great if you could make all the project files available to me. Then I could create a local Visual C++ project and see if I can give you some direct help.
Note that I use Windows 98, but that should not be an obstacle.
You can send me your files (perhaps as a Zip file attachment) by using the temporary email address formed by concatenating "ma" with "firstname.lastname@example.org". Please do not send any large files, as I have a slow dialup connection.
Bear in mind that all AllExperts messages are public.