You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
google.STT: no way to supply a project when authenticating with in-memory credentials (WIF / impersonated) #6772
Follow-up to #6618 (thank you @biztex for it - it solved the authentication half of this for us, you are a life saver!).
#6618 added a credentials parameter to google.STT and google.TTS, described as mirroring the parameter already accepted by RealtimeModel, LLM and the aiplatform LLM. Those classes also accept a project parameter, and STT does not - which leaves in-memory credentials unusable for Speech-to-Text v2 even after #6618.
Workarounds / Alternatives
Attaching a quota project makes the getattr fallback succeed:
This works, and we are shipping it. Two reasons it is not a good long-term answer:
quota_project_id designates where API quota and billing are attributed. It is not a statement about where the recognizer resource lives. The two coincide in our deployment but are separable in general.
It requires serviceusage.services.use on the named project, which is a permission grant that has nothing to do with speech recognition.
Additional Context
TTS needs no project: it works fine with credentials= alone, and we have it in production.
STT v2 addresses a recognizer resource, so it needs a project id:
_create_client resolves that from the credentials object (stt.py:323):
ifis_given(self._credentials):
ifself._project_idisNone:
# in-memory credentials (e.g. Workload Identity Federation) may# carry the project directly; resolve it here so _get_recognizer# doesn't fall back to Application Default Credentials, which# such setups typically don't haveself._project_id=getattr(self._credentials, "project_id", None) orgetattr(
self._credentials, "quota_project_id", None
)
The comment anticipates our exact case, but google.auth.impersonated_credentials.Credentials exposes neither attribute:
So _project_id stays None, and _get_recognizer falls through to google.auth.default() - which a Workload Identity Federation container has none of, by design. There is no parameter through which to supply the project instead.
Activity