Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I'm new to programming so My apologies to all.
My question is Question is can the code below written in c# be converted to python?

recognizer.LoadGrammar(new Grammar(new GrammarBuilder(new Choices(File.ReadAllLines(@"txt file location")))));

What I have tried:

I tried this

self.__recognizer.LoadGrammar(Grammar(GrammarBuilder(Choices(File.ReadAllLines("txt file location")))))
Posted
Updated 8-Oct-18 4:54am
Comments
Sinisa Hajnal 10-Mar-16 2:41am    
Yes it can be. You don't have to convert it literally. Feel free to use multiple lines for ease of reading and maintenance.

1 solution

This can't be simply converted to Python because it uses the C# GrammarBuilder Class (Microsoft.Speech.Recognition)[^].

So you have to look if there is some Python library providing similar functionality using the Speech Recognition Grammar Specification Version 1.0[^].

But this requires to understand what the C# code is doing and how similar operations can be implemented with Python.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900