Skip to content

Commit

Permalink
enh: Update to also pass ClientOptions to credentials args (#1098)
Browse files Browse the repository at this point in the history
  • Loading branch information
brightsparc authored Jan 31, 2025
1 parent a874f37 commit e5cfd32
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-phones-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-plugins-google": patch
---

Update to support passing chirp_2 location for other STT credentials
1 change: 1 addition & 0 deletions livekit-plugins/install_plugins_editable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pip install -e ./livekit-plugins-azure --config-settings editable_mode=strict
pip install -e ./livekit-plugins-cartesia --config-settings editable_mode=strict
pip install -e ./livekit-plugins-deepgram --config-settings editable_mode=strict
pip install -e ./livekit-plugins-elevenlabs --config-settings editable_mode=strict
pip install -e ./livekit-plugins-fal --config-settings editable_mode=strict
pip install -e ./livekit-plugins-google --config-settings editable_mode=strict
pip install -e ./livekit-plugins-minimal --config-settings editable_mode=strict
pip install -e ./livekit-plugins-nltk --config-settings editable_mode=strict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,26 @@ def __init__(
self._streams = weakref.WeakSet[SpeechStream]()

def _ensure_client(self) -> SpeechAsyncClient:
# Add support for passing a specific location that matches recognizer
# see: https://cloud.google.com/speech-to-text/v2/docs/speech-to-text-supported-languages
client_options = None
if self._location != "global":
client_options = ClientOptions(
api_endpoint=f"{self._location}-speech.googleapis.com"
)
if self._credentials_info:
self._client = SpeechAsyncClient.from_service_account_info(
self._credentials_info
self._credentials_info,
client_options=client_options,
)
elif self._credentials_file:
self._client = SpeechAsyncClient.from_service_account_file(
self._credentials_file
self._credentials_file,
client_options=client_options,
)
elif self._location == "global":
self._client = SpeechAsyncClient()
else:
# Add support for passing a specific location that matches recognizer
# see: https://cloud.google.com/speech-to-text/v2/docs/speech-to-text-supported-languages
self._client = SpeechAsyncClient(
client_options=ClientOptions(
api_endpoint=f"{self._location}-speech.googleapis.com"
)
client_options=client_options,
)
assert self._client is not None
return self._client
Expand Down

0 comments on commit e5cfd32

Please sign in to comment.