question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

await SpeechSynthesizer Async methods crash without throwing an error

See original GitHub issue

I’m working in Visual Studio 2019 on a .Net Core 3.1 library and using Microsoft.CognitiveServices.Speech ver 1.18.0 and even with the simplest program imaginable:

using Microsoft.CognitiveServices.Speech;
using System;
using System.Net.Http;
using System.Threading.Tasks;

namespace TextToSpeech
{
    public class SimpleAzureTest
    {
        public static async Task SynthesizeAudioAsync()
        {
            var config = SpeechConfig.FromSubscription("My Key", "southcentralus");
            using var synthesizer = new SpeechSynthesizer(config);
            await synthesizer.SpeakTextAsync("Synthesizing directly to speaker output.");
        }
    }
}

When I try run this in Debug mode, I get until the await line and, then, the program just dies. I can’t wrap it in a try catch and am not getting back a HTTP result to examine, it simply dies and exits debug mode when trying to run the await line of code and the output window states The program '[15480] Tests.exe' has exited with code 0 (0x0).

I’ve checked my key and region in Azure and my subscription status is Active and doesn’t seem to have any issues in terms of hitting a call quota or anything else and I am able to use the same key and region to get results directly via the Microsoft REST API, so I’m really not sure what’s happening here.

How can I figure out the source of this issue / what can be done to fix it?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
yulin-licommented, Sep 28, 2021

I was using the following code to repro…

namespace ConsoleApp2
{
    using System.Threading.Tasks;
    using Microsoft.CognitiveServices.Speech;
    
    class Program
    {
        public static async Task Main(string[] args)
        {
            var config = SpeechConfig.FromSubscription("key", "westus");
            using var synthesizer = new SpeechSynthesizer(config);
            await synthesizer.SpeakTextAsync("Synthesizing directly to speaker output.");
        }
    }
}
0reactions
origflacommented, Sep 28, 2021

Yulin, thank you so much for your help with this - I ended up re-writing the class library and it ended up working. The more I think about it, the more I think it may have just been a corrupt file in my csproj or something because nothing else really made much sense.

The point is it is working now and I’m chalking this up to a VS issue rather than a library one. Thank you SO much for oyur time, help and thought on this!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Async method exception crashing application
After hitting the internal error (which is only visible with 'Just My Code' disabled in VS settings), it goes onto a System.Threading.Tasks.
Read more >
Curious Case of Exceptions in Async Methods — Part 2
The below code shows an async method that returns Task, has no await statement and throws an exception. This code is almost identical...
Read more >
[Solved]-Why is an exception swallowed in an async action in ...
Because the action is asynchronous. loadBranch() returns as soon as the first await is reached, and can't possibly throw the exception you're expecting ......
Read more >
Voice Attack 1.7.2 (steam version) crashing repeatedly
The software simply crashes without displaying any error. ... switching between synchronous and asynchronous modes using the "wait until ...
Read more >
Exception handling improvements for async void methods ...
When executed, instead of displaying “Exception in Main” message, this program crashes. Similar to this console application, all exceptions ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found