如何实际说出X#毫秒的静音而不是使用Thread.Sleep().我正在尝试使用SpVoice变量的SpeechLib库中的.Speak()函数,根据指定的毫秒数说出特定的静默持续时间.特别是,在.wav文件的输出中,其中我在语音文本行之间插入静默时段.使用Thread.Sleep()会花费大量的时间来说话或保存,因为我计划将近5000行语音文本保存到.wav,并在行之间暂停.
这是我到目前为止的解决方案:
int pauseA = (int)(22050.0 * ((double)pauseTargetToSource.Value / 1000.0) * 2.0);
int pauseB = (int)(22050.0 * ((double)pauseLineBreak.Value / 1000.0) * 2.0);
while (
(lineSource = srSource.ReadLine()) != null &&
(lineTarget = srTarget.ReadLine()) != null)
{
voiceSource.Speak(lineSource, SpeechVoiceSpeakFlags.SVSFlagsAsync);
voiceSource.WaitUntilDone(Timeout.Infinite);
voiceSource.AudioOutputStream.Write(new byte[pauseA]);
voiceTarget.Speak(lineTarget, SpeechVoiceSpeakFlags.SVSFlagsAsync);
voiceTarget.WaitUntilDone(Timeout.Infinite);
voiceSource.AudioOutputStream.Write(new byte[pauseB]);
}
Run Code Online (Sandbox Code Playgroud)
其中22050.0是采样率,pauseLineBreak.Value是毫秒数.乘法器2.0用于.wav数据中的短字节的2字节长度.
AudioOutputStream.Write只是将正确的#00写入文件以保持静音.
我正在尝试检索 Windows .lnk 快捷方式的目标路径,但根据 .lnk 文件的属性,“目标”不是实际文件路径:

我正在使用 IWshRuntimeLibrary 并且我正在访问的快捷方式对象是 IWshShortcut 类型:
WshShell shell = new WshShell();
IWshShortcut link = (IWshShortcut)shell.CreateShortcut(lnkFileName);
// This returns "C:\Windows\Installer\{F843C6A3-224D-4615-94F8-3C461BD9AEA0}\PaintShopProExeIcon.ico"
var targetPath = link.TargetPath;
// This is the same as the "Start in" value in the image above
var workingDir = link.WorkingDirectory;
Run Code Online (Sandbox Code Playgroud)
“链接”对象的 TargetPath 属性不是实际 .exe 的位置:“C:\Windows\Installer{F843C6A3-224D-4615-94F8-3C461BD9AEA0}\PaintShopProExeIcon.ico”
我可以从这个对象中获取 WorkingDirectory 属性,它似乎与上图中快捷方式的“Start in”属性相同。我的问题是,如果 TargetPath 不是实际的 .exe 路径,我怎样才能获得快捷方式打开的 .exe 文件的实际目标路径?这些信息在哪里?
本示例中的实际目标路径为“C:\Program Files (x86)\Jasc Software Inc\Paint Shop Pro 9\Paint Shop Pro 9.exe”。系统是如何知道具体打开“Paint Shop Pro.exe”的?