0

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.

  • 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 Answers1

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