-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Description
When using System.Speech with a voice provided by SAPIForVOICEVOX, System.Speech crashes the entire program. I have tried calling the SpeechSynthesizer.Speak and SpeechSynthesizer.SpeakAsync methods within a try-catch block to to at least prevent the crash, but it did not work.
Note that these voices function as expected when used with Windows Narrator without any issues whatsoever.
Here's the exception I get:
Unhandled exception at 0x00007FFA2C1B1A21 (ntdll.dll) in JL.exe.12272.dmp: Unknown __fastfail() status code: 0x0000000000000030.
Here's the dump file in case it's useful:
https://uploadnow.io/en/share?utm_source=P8d7wy4
Reproduction Steps
-
Install VOICEVOX and SAPIForVOICEVOX. (Be sure to read the README of SAPIForVOICEVOX)
-
Make sure the installed voice appears under:
Windows Settings → Ease of Access → Narrator → Personalize Narrator's voice → Choose a voice dropdown menu. -
Turn on Windows Narrator to confirm that it works with a voice provided by SAPIForVOICEVOX.
-
Try using the same voice with
System.Speech, using code similar to the following:try { SpeechSynthesizer speechSynthesizer = new(); speechSynthesizer.SelectVoice(voiceName); // The voice you've tested with Narrator, e.g., "VOICEVOX 四国めたん ささやき" speechSynthesizer.SetOutputToDefaultAudioDevice(); speechSynthesizer.Speak("テスト"); } catch (Exception ex) { Debug.WriteLine(ex.Message); // Program crashes before reaching this line, boohoo! }
-
Observe the crash.
Expected behavior
System.Speech should be able to use voices provided by SAPIForVOICEVOX, just as Windows Narrator does, and it should definitely not cause the entire program to crash.
Actual behavior
System.Speech causes the entire program to crash, and even a try-catch block does not prevent the crash.
Regression?
No response
Known Workarounds
No response
Configuration
Which version of .NET is the code running on?
.NET 9
What OS and version, and what distro if applicable?
Windows 10, 22H2
What is the architecture (x64, x86, ARM, ARM64)?
x64
Other information
Upon examining the dump file, it seems that the exception occurs in the GetOutputFormat method of the TtsProxySapi class. The issue arises at line 27, where _sapiEngine.GetOutputFormat(ref pTargetFmtId, preferredFormat, out pOutputFormatId, out ppCoMemOutputWaveFormatEx) is invoked.