-
Sep 4th, 2015, 02:07 PM
#1
Thread Starter
New Member
[RESOLVED] Load grammar from project reference
I’m currently loading a grammar file using a static filename. This works but I need to start loading the file as a project resource. I can add the file as a project resource but can’t figure out how the load the resource string to the grammar. Any suggestions are greatly appreciated.
Code:
'Current load grammar line
reco.LoadGrammar(New Recognition.Grammar("C:\Users\jc11834\Desktop\TV Grammar.xml"))
-
Sep 4th, 2015, 11:38 PM
#2
Re: Load grammar from project reference
Hi and Welcome to the Forum,
When you add a file as a Resource in your project then the way to read is back is to just assign the file to basic string variable, such as:-
vb.net Code:
Dim fileContents As String = My.Resources.YourXMLFileName
However, it’s your Grammar Class that needs the most work. At the moment you are passing a Filename through the Classes Constructor which then reads the file and returns an object of type Grammer which is then used in your LoadGrammer Method. What you will need to do here is to add an Overload to your existing Constructor which accepts a String Variable, processes the contents of that String and finally returns an object of Type Grammer. Once done you could then use your LoadGrammer Method in the following manner:-
vb.net Code:
reco.LoadGrammar(New Recognition.Grammar(My.Resourses.YourXMLFileName))
Hope that helps.
Cheers,
Ian
-
Sep 5th, 2015, 07:32 AM
#3
Thread Starter
New Member
Re: Load grammar from project reference
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|