S
S
stdio962018-12-07 19:42:20
C++ / C#
stdio96, 2018-12-07 19:42:20

How to add grammar file to finished exe file?

Hello.
There is an xml file for SRGS grammar.

<?xml version="1.0" encoding="UTF-8"?>
<grammar version="1.0" xml:lang="en-US"
         xmlns="http://www.w3.org/2001/06/grammar"
         tag-format="semantics/1.0" root="Main">

Now it is connected in this way (statically).
Grammar citiesGrammar = new Grammar(@"C:\[путь к файлу].xml");
recEngine.LoadGrammar(citiesGrammar);

At this point, it must be copied to the computer on which it should be launched (of course, at the same address). I added it to the resources, but when I try to pass it to the Grammar constructor, it gives an error that the path is not the same. I agree with this, because. it gives the contents of the file.
There are 2 questions:
1. The question is how to add it to the finished exe-file (after the Release compilation)?
2. It is necessary to implement 2 languages ​​for voice acting. I found how to change the language in SpeechSynthesizer, but now the issue is with strings. say("Hello"); Is it worth doing 2 xml-files or is it possible through resources (example: hello_en = "Hello", hello_ru = "Hello"). And then just call something like this (if possible): say(resource.phrases.hello_ + lang); There are literally a few lines. This does not apply to the Grammar xml file.
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sumor, 2018-12-07
@stdio96

Grammar has a constructor that takes a Stream.
Accordingly, you represent the resource as a Stream (for example, via GetManifestResourceStream) and substitute it in the constructor.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question