0
votes

Is there a way to programatically list the available voices in Azure Text To Speech?

I've searched extensively and found this page https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/language-support

But I have not found any way to get this information programatically - is it possible?

3

3 Answers

1
votes

There is voices/list endpoint and it is documented here.

Example from the documentation:

GET /cognitiveservices/voices/list HTTP/1.1

Host: westus.tts.speech.microsoft.com
Authorization: Bearer [Base64 access_token]
0
votes

As per the documentation mentioned in the swagger, you could use the

api/languagegeneration/v2.0/Endpoints/locales

end point to get the supported locales.

/api/texttospeech/v2.0/datasets/locales
0
votes

Since 1.16.0 there is...

SpeechSynthesizer.GetVoicesAsync(string locale)

var config = SpeechConfig.FromSubscription("YourSubscriptionKey", "YourServiceRegion");            
using var synthesizer = new SpeechSynthesizer(config, null as AudioConfig);
using var result = await synthesizer.GetVoicesAsync();
if (result.Reason == ResultReason.VoicesListRetrieved)
{
    Debug.WriteLine($"Found {result.Voices.Count} voices");
}

There is a working example SynthesisGetAvailableVoicesAsync() method in the Azure-Samples github respository... there is a direct link to the Text-to-Speech samples at the top of the Text-to-speech quickstart page.