I am developing an application in C# where I would like to read from a simple text file. So how to give input(the file) to speak synthesis Engine.Speak() method.
Asked
Active
Viewed 1,085 times
0
-
Have you got any idea yet? or maybe some code to show us how far is your progress. We really want you to **Learn** instead of just copy and paste. Also , I still don't understand your need , do you want how to get input from file into program , or you already have input into your program but you want to speak it out. – Poomrokc The 3years Jun 21 '14 at 11:04
-
As of now, I am only giving the Speak() method some predefined strings. I just want to know how to do it for a file instead. – user3755903 Jun 21 '14 at 11:09
1 Answers
0
According to your comment and this guide
I'll give you example how to get a text file's content into your program.
Example 1: Read all text and save into string.
string alltext= System.IO.File.ReadAllText(@"read.txt");
Engine.Speak(alltext); //put the string into your command
Example 2: Read each line of file and save into string array.
string[] eachlinetext = System.IO.File.ReadAllLines(@"C:\Users\Public\TestFolder\WriteLines2.txt");
Engine.Speak(eachlinetext[0]); // speak the first line of the file
Hope it helps you. Also , Happy Programming!!

Poomrokc The 3years
- 1,099
- 2
- 10
- 23
-
This is exactly what I want. Secondly, how to do reverse of that as in how to give the recognizer an audio file as input. – user3755903 Jun 21 '14 at 11:35
-
do you have an engine to assign the regcognized text into string? – Poomrokc The 3years Jun 21 '14 at 11:56
-
I hope it could be done using Speech Recognition Engine provided in System.Speech.Recognition. – user3755903 Jun 25 '14 at 06:42
-
I think it could be done using Speech Recognition Engine in System.Speech – user3755903 Jun 25 '14 at 07:04
-
@user3755903 see this article http://msdn.microsoft.com/en-us/library/system.speech.recognition.speechrecognitionengine.setinputtoaudiostream.aspx . WARNING:You may be dissappointed by speech regcognition engine. So be patient doing things with this stuff. – Poomrokc The 3years Jun 26 '14 at 10:32