Beispiel #1
0
 private void btnReadFile_Click(object sender, EventArgs e)
 {
     try
     {
         if (!System.IO.File.Exists(txtFileToRead.Text))
         {
             return;
         }
         spGen.SpeakAsync(System.IO.File.ReadAllText(txtFileToRead.Text));
     }
     catch { }
 }
Beispiel #2
0
        /// <summary>
        /// Executes the aread command
        /// </summary>
        /// <param name="command">Command object which contains the command to be executed</param>
        /// <returns>The Response object result of provided command execution. If no response is required, must return null</returns>
        /// <remarks>If the command execution is aborted the execution of this method is
        /// canceled and a failure response is sent if required</remarks>
        protected override Response AsyncTask(Command command)
        {
            bool   result;
            string textToSay;

            result = false;
            try
            {
                if (File.Exists(command.Parameters))
                {
                    textToSay = System.IO.File.ReadAllText(command.Parameters);
                    result    = spGen.SpeakAsync(textToSay);
                }
            }
            catch
            {
                result = false;
            }

            return(Response.CreateFromCommand(command, result));
        }
Beispiel #3
0
        /// <summary>
        /// Executes the read command
        /// </summary>
        /// <param name="command">Command object which contains the command to be executed</param>
        /// <returns>The Response object result of provided command execution. If no response is required, must return null</returns>
        /// <remarks>If the command execution is aborted the execution of this method is
        /// canceled and a failure response is sent if required</remarks>
        protected override Response AsyncTask(Command command)
        {
            bool           result;
            string         textToSay;
            SpeechTextTask task;

            result = false;
            try
            {
                if (File.Exists(command.Parameters))
                {
                    textToSay = System.IO.File.ReadAllText(command.Parameters);
                    //if (spGen.IsSpeaking || (spGen.Pending > 0))
                    //    result = false;
                    //else
                    //    result = spGen.SpeakSync(textToSay);

                    task = new SpeechTextTask(textToSay);
                    if (!spGen.SpeakAsync(task))
                    {
                        return(Response.CreateFromCommand(command, false));
                    }
                    while ((task.Status == SpeechTextTaskStatus.Pending) || (task.Status == SpeechTextTaskStatus.Speaking))
                    {
                        System.Threading.Thread.Sleep(1);
                    }
                    result = task.Status == SpeechTextTaskStatus.CompletedSuccessfully;
                }
            }
            catch
            {
                result = false;
            }

            return(Response.CreateFromCommand(command, result));
        }