-
Jan 18th, 2021, 08:37 AM
#1
Thread Starter
New Member
Speech to Text question
Would it be feasible to use the speech recognition engine to record text from a movie in the form of a wave file? In perusing sample code for the speech objects, it seems that perhaps the only words recognized would have to be in the choices object. Is that a false assumption on my part?
-
Jan 20th, 2021, 11:07 PM
#2
Member
Re: Speech to Text question
Hello, @DonaldJamesParker
Please try this code, To Speech to Text question.
Here is a quick sample that shows one of the simplest .NET windows forms app to use a dictation grammar that I could think of. This should work on Windows Vista or Windows 7. I created a form. Dropped a button on it and made the button big. Added a reference to System.Speech and the line:
Code:
using System.Speech.Recognition;
Then I added the following event handler to button1:
Code:
private void button1_Click(object sender, EventArgs e)
{
SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine();
Grammar dictationGrammar = new DictationGrammar();
recognizer.LoadGrammar(dictationGrammar);
try
{
button1.Text = "Speak Now";
recognizer.SetInputToDefaultAudioDevice();
RecognitionResult result = recognizer.Recognize();
button1.Text = result.Text;
}
catch (InvalidOperationException exception)
{
button1.Text = String.Format("Could not recognize input from default aduio device. Is a microphone or sound card available?\r\n{0} - {1}.", exception.Source, exception.Message);
}
finally
{
recognizer.UnloadAllGrammars();
}
}
A little more information comparing the various flavors of speech engines and APIs shipped by Microsoft can be found.
I hope this code will be useful to you.
Thank you,
< advertising removed by moderator >
-
Jan 21st, 2021, 09:19 PM
#3
Thread Starter
New Member
Re: Speech to Text question
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
|