Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always getting Reason [ResultReason]: Cancel #1712

Closed
tango4567 opened this issue Oct 27, 2022 · 2 comments
Closed

Always getting Reason [ResultReason]: Cancel #1712

tango4567 opened this issue Oct 27, 2022 · 2 comments
Assignees

Comments

@tango4567
Copy link

While I'm truing to convert text to speech in C# I'm always getting cancelled response. Why I'm getting Reason [ResultReason]: Cancel even after providing correct details. We are using Standard Tire plan also. So I would like to request you please guide me. I tried multiple time but always getting same response.

Code
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.CognitiveServices.Speech;
using Microsoft.CognitiveServices.Speech.Audio;

class Program 
{
    static string speechKey = "1234567890";  //replaced 
    static string speechRegion = "someWhereOnMars";  //replaced 

    static void OutputSpeechSynthesisResult(SpeechSynthesisResult speechSynthesisResult, string text)
    {
        Console.WriteLine($"Tango Reason: {speechSynthesisResult.Reason}");
        switch (speechSynthesisResult.Reason)
        {
            case ResultReason.SynthesizingAudioCompleted:
                Console.WriteLine($"Speech synthesized for text: [{text}]");
                break;
            case ResultReason.Canceled:
                var cancellation = SpeechSynthesisCancellationDetails.FromResult(speechSynthesisResult);
                Console.WriteLine($"CANCELED: Reason={cancellation.Reason}");

                if (cancellation.Reason == CancellationReason.Error)
                {
                    Console.WriteLine($"CANCELED: ErrorCode={cancellation.ErrorCode}");
                    Console.WriteLine($"CANCELED: ErrorDetails=[{cancellation.ErrorDetails}]");
                    Console.WriteLine($"CANCELED: Did you set the speech resource key and region values?");
                }
                break;
            default:
                break;
        }
    }

    async static Task Main(string[] args)
    {
        var speechConfig = SpeechConfig.FromSubscription(speechKey, speechRegion);      

        // The language of the voice that speaks.
        speechConfig.SpeechSynthesisVoiceName = "en-US-JennyNeural"; 

        using (var speechSynthesizer = new SpeechSynthesizer(speechConfig))
        {
            // Get text from the console and synthesize to the default speaker.
            string text  = "Enter some text that you want to speak ";

            var speechSynthesisResult = await speechSynthesizer.SpeakTextAsync(text);
            OutputSpeechSynthesisResult(speechSynthesisResult, text);
        }

        Console.WriteLine("Press any key to exit...");
        Console.ReadKey();
    }
}
@ralph-msft ralph-msft self-assigned this Oct 27, 2022
@ralph-msft
Copy link

To be able to better assist you, could you please:

  • Share the SDK logs?
  • Include the details of which OS you are using, and the SDK version?

@ralph-msft
Copy link

Closing due to inactivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants