public async Task <ActionResult> Index(IEnumerable <HttpPostedFileBase> files)
        {
            ///
            ///
            //step 1 : upload
            ///
            ///

            OperationResult operationResult = new OperationResult();
            Uploader        uploader        = new Uploader(files);

            uploader.Upload(operationResult);

            if (operationResult.StatusStr == OperationResultStatus.Fail)
            {
                // if file upload was not successful
                // we return a JSON to the INDEX controller as a result of failure
                // and the process will stop here
                return(FailJSON(operationResult));
            }


            ///
            ///
            //step 2 : ocr
            ///
            ///

            OcrClass ocr = new OcrClass(operationResult.ImageStorageDirectory, operationResult.ImageFileName);

            ocr.Ocr(operationResult);

            if (operationResult.StatusStr == OperationResultStatus.Fail)
            {
                // if file OCR process on the image file was not successfull
                // we return a JSON to the INDEX controller as a result of failure
                // and the process will stop here
                return(FailJSON(operationResult));
            }


            ///
            ///
            //step 3 : speech
            ///
            ///

            Task <JsonResult> task = Task.Run(() =>
            {
                SpeechClass speechClass = new SpeechClass();
                speechClass.speech(operationResult);

                //using (SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer())
                //{
                //    string fileName = "ImageToSpeech_" + Guid.NewGuid();
                //    speechSynthesizer.SetOutputToWaveFile(Server.MapPath("~/SpeechFiles/") + fileName + ".wav");
                //    speechSynthesizer.Speak(operationResult.textToSpeechString);
                //}

                //letting the server master file save the image on disk
                Task.Delay(500);

                if (operationResult.StatusStr == OperationResultStatus.Success)
                {
                    return(SuccessJSON(operationResult));
                }
                else
                {
                    return(FailJSON(operationResult));
                }
            });


            return(await task);
        }
Example #2
0
 public void Add(SpeechClass c)
 {
     if (!speechClasses.Contains(c))
         speechClasses.Add(c);
 }
Example #3
0
 static void Populate(WordMatrix matrix, string word, SpeechClass c)
 {
     matrix.Add(word, new SpeechClass[] { c });
 }