So, after digging, with the clues here [https://learn.microsoft.com/en-us/answers/questions/1184428/azure-text-to-speech-error-code-0x38-(spxerr-audio](https://learn.microsoft.com/en-us/answers/questions/1184428/azure-text-to-speech-error-code-0x38-(spxerr-audio), I found the solution..
Just have to add an AudioConfig to the constructor pointing to anything but speaker or microphone (they do not exist on Azure machines).
public static async Task<VoiceInfo> GetVoice(this SpeechConfig config, string localeid)
{
var audio_config = AudioConfig.FromStreamOutput(new PullAudioOutputStream());
using (var synthesizer = new SpeechSynthesizer(config, audio_config))
{
using (var voices = await synthesizer.GetVoicesAsync())
{
var voice = voices.Voices.FirstOrDefault(voice => voice.Locale == localeid) ??
voices.Voices.First(voice => voice.Locale == defaultLocale);
return voice;
}
}
}