Unhandled exception thrown by System.Speech when using it with SAPIForVOICEVOX
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- csharp
- Domain
- audio-video-rtc, desktop
Research direction
Start by reproducing the crash with .NET 9 on Windows 10 using SAPIForVOICEVOX and the supplied sample, then inspect the dump around TtsProxySapi.GetOutputFormat, especially line 27 and the _sapiEngine.GetOutputFormat call. Confirm the failure path and whether it can be handled without terminating the process; done should include a regression test or documented verification for the affected voice.
Written by the indexing model from the issue text.
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.
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/runtime
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
area-System.Reflection blocking-clean-ci-optional Known Build Error os-mac-os-x untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
area-CodeGen-coreclr untriaged
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
agentic-workflows untriaged
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
area-VM-meta-mono untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
Create parent directories only after the containment check in InstallHelper.TryExtractToDirectory Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PowerShell/PSResourceGet#2056 ·