From 4b5125377cdc368ec5a31f4b2443e299a5461e6b Mon Sep 17 00:00:00 2001 From: ray45422 Date: Mon, 4 May 2026 19:36:20 +0900 Subject: [PATCH] =?UTF-8?q?VOICEPEAK=E3=81=8C=E3=82=A4=E3=83=B3=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=83=BC=E3=83=AB=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88=E3=81=AB=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=81=8C=E7=99=BA=E7=94=9F=E3=81=97=E9=9F=B3=E6=BA=90?= =?UTF-8?q?=E5=88=97=E6=8C=99=E3=81=AB=E5=A4=B1=E6=95=97=E3=81=99=E3=82=8B?= =?UTF-8?q?=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit レジストリからインストール先のパスを取得できなかった場合にVOICEPEAKのパスが空になり、プロセスの起動に失敗し他の音源の列挙処理が失敗していたためパスをチェックし空の場合は実行しないように変更 存在しないパスで実行された場合にも終了しないよう変更 --- src/Speech/Controller/VOICEPEAKEnumerator.cs | 34 ++++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/Speech/Controller/VOICEPEAKEnumerator.cs b/src/Speech/Controller/VOICEPEAKEnumerator.cs index d9bf66d..c75cda7 100644 --- a/src/Speech/Controller/VOICEPEAKEnumerator.cs +++ b/src/Speech/Controller/VOICEPEAKEnumerator.cs @@ -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; @@ -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; @@ -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; } }