小编gia*_*olo的帖子

如何使用SpVoice在C#中说毫秒的静音?

如何实际说出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写入文件以保持静音.

c#

15
推荐指数
1
解决办法
705
查看次数

使用“Start in”目录获取 Windows .lnk 快捷方式的目标

我正在尝试检索 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”的?

c# wsh shortcut lnk windows-8.1

5
推荐指数
0
解决办法
2710
查看次数

标签 统计

c# ×2

lnk ×1

shortcut ×1

windows-8.1 ×1

wsh ×1