Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions src/Speech/Controller/VOICEPEAKEnumerator.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

Expand All @@ -25,6 +27,10 @@ public VOICEPEAKEnumerator()

private string[] ExecuteVoicepeak(string args)
{
if (string.IsNullOrEmpty(path))
{
return new string[0];
}
ProcessStartInfo psInfo = new ProcessStartInfo();

psInfo.FileName = path;
Expand All @@ -33,15 +39,29 @@ private string[] ExecuteVoicepeak(string args)
psInfo.RedirectStandardOutput = true;
psInfo.Arguments = args;

using (Process p = Process.Start(psInfo))
try
{
// Voicepeakは非同期実行されるのでプロセス終了後に標準出力を取り出す
p.WaitForExit(10);
using (Process p = Process.Start(psInfo))
{
// Voicepeakは非同期実行されるのでプロセス終了後に標準出力を取り出す
p.WaitForExit(10);

// 行の整形
string[] stdout = p.StandardOutput.ReadToEnd().Split('\n');
string[] output = stdout.Where(x => x.Trim().Length > 0).Select(x => x.Trim()).ToArray();
return output;
// 行の整形
string[] stdout = p.StandardOutput.ReadToEnd().Split('\n');
string[] output = stdout.Where(x => x.Trim().Length > 0).Select(x => x.Trim()).ToArray();
return output;
}
}
catch (Win32Exception e)
{
int error = Marshal.GetLastWin32Error();
switch (error)
{
case 2:
// ERROR_FILE_NOT_FOUND
return new string[0];
}
throw e;
}
}

Expand Down