FEAT: Deprecate use_entra_auth and add auto-detect auth for Azure Speech converters#1634
Conversation
| } | ||
| ) | ||
|
|
||
| async def _get_speech_config_async(self) -> "speechsdk.SpeechConfig": |
There was a problem hiding this comment.
wonder if this whole method could belong in azure_auth as a helper?
There was a problem hiding this comment.
esp since we have identical method in other converter
There was a problem hiding this comment.
wonder what you thought about making this into a shared helper method?
| *, | ||
| text_capable_scorer: Scorer, | ||
| use_entra_auth: Optional[bool] = None, | ||
| use_entra_auth: bool | None = None, |
There was a problem hiding this comment.
this should probably stay as Optional[bool] type to match other classes right?
| azure_speech_key: Optional[str | Callable[[], str | Awaitable[str]]] = None, | ||
| azure_speech_resource_id: Optional[str] = None, | ||
| use_entra_auth: bool = False, | ||
| use_entra_auth: Optional[bool] = None, |
There was a problem hiding this comment.
Does this mean the default behavior (with env vars set, no args provided) changes from not using Entra to using Entra now?
|
|
||
| try: | ||
| converter = AzureSpeechAudioToTextConverter(use_entra_auth=self._use_entra_auth) | ||
| converter = AzureSpeechAudioToTextConverter() |
There was a problem hiding this comment.
Doesn't it require the resource ID? At least that's how I read the docstirng.
There was a problem hiding this comment.
it could get grabbed from environment variables! Wonder if we want the resource ID and api_Key to be passed into inits of scorers that use converters or if that's overcomplicating..
There was a problem hiding this comment.
True. Saw that afterwards. What do y mean by scorers? Audio scorers?
| converter = AzureSpeechAudioToTextConverter( | ||
| azure_speech_region=region, azure_speech_resource_id=resource_id, use_entra_auth=True | ||
| ) | ||
| converter = AzureSpeechAudioToTextConverter(azure_speech_region=region, azure_speech_resource_id=resource_id) |
There was a problem hiding this comment.
Default behavior changed here. Perhaps we should use an API key if it is provided as env var?
Also, no changes required for the API-key-based integration test?
| azure_speech_region (str | None): The name of the Azure region. | ||
| azure_speech_key (str | Callable[[], str | Awaitable[str]] | None): The API key for accessing | ||
| the service, or a sync/async callable that returns a token string. | ||
| If a string key is provided (or the ``AZURE_SPEECH_KEY`` env var is set), key auth is used. | ||
| If a callable token provider is provided, it is resolved at conversion time and used with | ||
| Entra ID auth (``azure_speech_resource_id`` must also be set). | ||
| If omitted, Entra ID auth via ``DefaultAzureCredential`` is used automatically. | ||
| azure_speech_resource_id (str | None): The resource ID for accessing the service when using | ||
| Entra ID auth. Required when using a callable token provider or when no API key is available. | ||
| use_entra_auth (bool | None): **Deprecated.** Will be removed in v0.15.0. |
There was a problem hiding this comment.
NIT: these types in the docstring should also say Optional[...]
| self._azure_speech_key = key_value | ||
| else: | ||
| logger.info( | ||
| "No azure_speech_key provided. Falling back to Entra ID authentication via DefaultAzureCredential." |
There was a problem hiding this comment.
NIT: Would it be more accurate to say Entra ID authentication will be attempted via DefaultAzureCredential since auth doesn't actually occur now but rather at convert time?
Description
Deprecates the
use_entra_authparameter across both Azure Speech converters and the scorer pass-through chain, replacing it with auto-detection logic that matches the OpenAI target pattern.Auth is now resolved automatically:
azure_speech_key(orAZURE_SPEECH_KEYenv var) -> API key authazure_speech_key(sync or async token provider) -> Entra token auth viaaad#{resource_id}#{token}formatDefaultAzureCredential+azure_speech_resource_idThe deprecated
use_entra_authparam is kept with aDeprecationWarning(removal target: v0.15.0) for backward compatibility.Note: Both converters now enforce keyword-only args (
*) per style guide. All existing callers already use keyword args, but this is technically a breaking change for positional usage. Also,azure_speech_keyis no longer visible in the backend converter catalog since its type changed fromOptional[str]toUnion[str, Callable, None]- users configure the key via theAZURE_SPEECH_KEYenv var in the backend.Files changed:
azure_speech_text_to_audio_converter.py- primary targetazure_speech_audio_to_text_converter.py- identical auth logicaudio_transcript_scorer.py,audio_true_false_scorer.py,audio_float_scale_scorer.py- deprecate pass-through param.env_example- updated commentTests and Documentation
doc/code/converters/2_audio_converters.py/.ipynb) don't useuse_entra_auth- no JupyText changes needed