Azure / Azure/azure-sdk-for-python

Python Speech SDK fails with "USP error: timeout waiting for the first audio chunk" when using managed identity authentication

Aperta
#40,112 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Client Cognitive - Speech needs-team-attention Service Attention
Lingua principale
Python
Stelle
5.6k
Fork
3.4k
Merge medio
2g
PR unite (30g)
217

Descrizione

1. Environment Details:
- Python SDK version: 1.42.0
- Authentication: Using DefaultAzureCredential (falling back to Azure CLI)
- Token acquisition is successful (token starts with "eyJ0eXAiOi...")
- Identical configuration works successfully in C# but fails in Python
2. Tested Approaches:
- Using the raw token directly: speech_config.authorization_token = token
- Using a formatted token like C#: aad#{resourceId}#{token}
- Setting token via property ID: set_property(SpeechServiceAuthorization_Token, token)
- Setting auth type explicitly: set_property(SpeechServiceAuthorization_Type, "Bearer")
- Using a single synthesizer for all segments (like C# does)
- Using standard voices instead of HD voices
- Using simplified SSML without custom parameters
3. Error Details:
- Synthesis appears to start (synthesizer is created successfully)
- Service times out after ~80 seconds
- Error is always: "USP error: timeout waiting for the first audio chunk"
- No audio data is received despite successful token acquisition
4. Working C# Implementation:

` private static async Task GetAiServicesAuthorizationTokenAsync(CancellationToken cancellationToken)
{
const string scope = "https://cognitiveservices.azure.com/.default";
var tokenCredential = new DefaultAzureCredential();
var token = await tokenCredential.GetTokenAsync(new Azure.Core.TokenRequestContext([scope]), cancellationToken);
return token.Token;
}

// Later used with:
var authorizationToken = await GetAiServicesAuthorizationTokenAsync(cancellationToken);
var speechConfig = SpeechConfig.FromAuthorizationToken($"aad#{speechResourceId}#{authorizationToken}", speechRegion);`

We've ruled out most common issues (token formatting, SSML structure, voice selection), this appears to be either:
1. A limitation in the Python SDK's implementation for managed identity
2. A possible network/connectivity issue specific to the Python SDK
3. An undocumented requirement for additional configuration when using managed identity with Python

Here is a [repro script](https://gist.github.com/robotdad/e61662b34016d8b395187c37525f7771).

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con lo script di riproduzione collegato e riproduci il timeout usando Python SDK 1.42.0, DefaultAzureCredential e SpeechConfig.FromAuthorizationToken. Confronta il flusso di autenticazione Python con la configurazione C# funzionante e i formati dei token testati. Il lavoro è completato quando viene identificata una causa confermata nell’SDK o nella configurazione e il problema di sintesi vocale con identità gestita viene documentato o risolto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
azure, python
Ambito
api, authentication, cloud
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.