Exemple #1
0
        private void Summarize_Click(object sender, RoutedEventArgs e)
        {
            string fin  = " ";
            string fout = " ";

            System.Windows.Forms.MessageBox.Show("Choose text file");
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                fin = openFileDialog1.FileName;
                System.Windows.Forms.MessageBox.Show(fin);
            }

            System.Windows.Forms.MessageBox.Show("Choose output file");
            OpenFileDialog openFileDialog2 = new OpenFileDialog();

            if (openFileDialog2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                fout = openFileDialog2.FileName;
                System.Windows.Forms.MessageBox.Show(fout);
            }

            string path = fout;                      //path to refined text

            File.WriteAllText(path, String.Empty);   //clear temp file
            StreamWriter sw = File.AppendText(path); //pointer to write to temp file

            ProcessStartInfo pythonInfo = new ProcessStartInfo();
            Process          python;

            pythonInfo.FileName               = @"C:\Users\Emmanuel\AppData\Local\Programs\Python\Python35\python.exe";
            pythonInfo.Arguments              = @"C:\Users\Emmanuel\Documents\Engineering_4\Degree\SpeechtoText\speech-to-text-wavenet-master\summarize.py" + " " + fin;
            pythonInfo.CreateNoWindow         = false;
            pythonInfo.UseShellExecute        = false;
            pythonInfo.RedirectStandardOutput = true;
            ConsoleManager.Show();
            Console.WriteLine("Python Starting");
            python = Process.Start(pythonInfo);
            StreamReader myStreamReader = python.StandardOutput;
            string       myString       = myStreamReader.ReadToEnd();

            python.WaitForExit();
            python.Close();

            sw.WriteLine("SUMMARY:");
            sw.WriteLine(" ");
            sw.WriteLine(myString);
            sw.Close();
            ConsoleManager.Hide();
        }