Exemplo n.º 1
0
        private void chapterListContextMenuStrip_Opening(object sender, CancelEventArgs e)
        {
            string novelTitle = dgvNovelList.SelectedRows[0].Cells["NovelTitle"].Value.ToString();

            Novel.ExportOption exportOption = Novel.ExportOption.None;
            if (Configuration.Instance.NovelExport.ContainsKey(novelTitle))
            {
                exportOption = Configuration.Instance.NovelExport[novelTitle];
            }
            switch (exportOption)
            {
            case Novel.ExportOption.None:
                exportOptionComboBox.SelectedItem = exportOptionComboBox.Items[0];
                break;

            case Novel.ExportOption.Audio:
                exportOptionComboBox.SelectedItem = exportOptionComboBox.Items[1];
                break;

            case Novel.ExportOption.Text:
                exportOptionComboBox.SelectedItem = exportOptionComboBox.Items[2];
                break;

            case Novel.ExportOption.Both:
                exportOptionComboBox.SelectedItem = exportOptionComboBox.Items[3];
                break;
            }
        }
Exemplo n.º 2
0
        //Launch an TTS executable with all the request's information.
        private void LaunchSubProcess(Request request)
        {
            string specifiedOutputAudioLocation = request.OutputAudioFile;
            string args = String.Format(" \"{0}\" -i \"{1}\" -o \"{2}\" -rate {3} -replace \"{4}\" -delete \"{5}\" -utf8",
                                        request.Voice, request.InputTextFile, request.OutputAudioFile, request.Rate, request.ReplacementFile, request.DeletionFile);
            Process p = new Process();

            p.StartInfo.FileName               = Path.Combine("TTS", "TTS.exe");
            p.StartInfo.UseShellExecute        = false;
            p.StartInfo.WorkingDirectory       = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
            p.StartInfo.Arguments              = args;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.CreateNoWindow         = true;
            p.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
            p.Start();
            StreamReader output = p.StandardOutput;
            string       line;

            while ((line = output.ReadLine()) != null)
            {
                int percent;
                if (Int32.TryParse(line, out percent))
                {
                    if (BackgroundService.Instance.ttsController.InvokeRequired)
                    {
                        BackgroundService.Instance.ttsController.BeginInvoke(new MethodInvoker(delegate
                        {
                            request.Progress = percent;
                        }));
                    }
                }
            }
            p.WaitForExit();
            //For if user rename file while the process is running
            if (!specifiedOutputAudioLocation.Equals(request.OutputAudioFile))
            {
                File.Copy(specifiedOutputAudioLocation, request.OutputAudioFile);
            }

            if (Configuration.Instance.AudioExportLocation != null)
            {
                string exportFolderLocation = Path.Combine(Configuration.Instance.AudioExportLocation, request.NovelTitle);

                if (!Directory.Exists(exportFolderLocation))
                {
                    Directory.CreateDirectory(exportFolderLocation);
                }

                if (Configuration.Instance.NovelExport.ContainsKey(request.Chapter.Novel.NovelTitle))
                {
                    Novel.ExportOption exportOption = Configuration.Instance.NovelExport[request.NovelTitle];
                    if (exportOption == Novel.ExportOption.Both || exportOption == Novel.ExportOption.Audio)
                    {
                        request.Chapter.ExportAudio(exportFolderLocation);
                    }
                }
            }
        }