livekit-plugins-google 1.0.17__py3-none-any.whl → 1.0.18__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,7 @@ from collections.abc import Iterator
9
9
  from dataclasses import dataclass
10
10
 
11
11
  from google import genai
12
+ from google.genai.live import AsyncSession
12
13
  from google.genai.types import (
13
14
  AudioTranscriptionConfig,
14
15
  Blob,
@@ -25,6 +26,7 @@ from google.genai.types import (
25
26
  Modality,
26
27
  Part,
27
28
  PrebuiltVoiceConfig,
29
+ SessionResumptionConfig,
28
30
  SpeechConfig,
29
31
  Tool,
30
32
  UsageMetadata,
@@ -62,6 +64,7 @@ class _RealtimeOptions:
62
64
  model: LiveAPIModels | str
63
65
  api_key: str | None
64
66
  voice: Voice | str
67
+ language: NotGivenOr[str]
65
68
  response_modalities: NotGivenOr[list[Modality]]
66
69
  vertexai: bool
67
70
  project: str | None
@@ -101,6 +104,7 @@ class RealtimeModel(llm.RealtimeModel):
101
104
  model: LiveAPIModels | str = "gemini-2.0-flash-live-001",
102
105
  api_key: NotGivenOr[str] = NOT_GIVEN,
103
106
  voice: Voice | str = "Puck",
107
+ language: NotGivenOr[str] = NOT_GIVEN,
104
108
  modalities: NotGivenOr[list[Modality]] = NOT_GIVEN,
105
109
  vertexai: bool = False,
106
110
  project: NotGivenOr[str] = NOT_GIVEN,
@@ -131,6 +135,7 @@ class RealtimeModel(llm.RealtimeModel):
131
135
  modalities (list[Modality], optional): Modalities to use, such as ["TEXT", "AUDIO"]. Defaults to ["AUDIO"].
132
136
  model (str, optional): The name of the model to use. Defaults to "gemini-2.0-flash-live-001".
133
137
  voice (api_proto.Voice, optional): Voice setting for audio outputs. Defaults to "Puck".
138
+ language (str, optional): The language(BCP-47 Code) to use for the API. supported languages - https://ai.google.dev/gemini-api/docs/live#supported-languages
134
139
  temperature (float, optional): Sampling temperature for response generation. Defaults to 0.8.
135
140
  vertexai (bool, optional): Whether to use VertexAI for the API. Defaults to False.
136
141
  project (str, optional): The project id to use for the API. Defaults to None. (for vertexai)
@@ -195,6 +200,7 @@ class RealtimeModel(llm.RealtimeModel):
195
200
  instructions=instructions,
196
201
  input_audio_transcription=input_audio_transcription,
197
202
  output_audio_transcription=output_audio_transcription,
203
+ language=language,
198
204
  )
199
205
 
200
206
  self._sessions = weakref.WeakSet[RealtimeSession]()
@@ -247,12 +253,14 @@ class RealtimeSession(llm.RealtimeSession):
247
253
  self._main_atask = asyncio.create_task(self._main_task(), name="gemini-realtime-session")
248
254
 
249
255
  self._current_generation: _ResponseGeneration | None = None
250
- self._active_session: genai.LiveSession | None = None
256
+ self._active_session: AsyncSession | None = None
251
257
  # indicates if the underlying session should end
252
258
  self._session_should_close = asyncio.Event()
253
259
  self._response_created_futures: dict[str, asyncio.Future[llm.GenerationCreatedEvent]] = {}
254
260
  self._pending_generation_fut: asyncio.Future[llm.GenerationCreatedEvent] | None = None
255
261
 
262
+ self._session_resumption_handle: str | None = None
263
+
256
264
  self._update_lock = asyncio.Lock()
257
265
  self._session_lock = asyncio.Lock()
258
266
 
@@ -465,7 +473,7 @@ class RealtimeSession(llm.RealtimeSession):
465
473
  finally:
466
474
  await self._close_active_session()
467
475
 
468
- async def _send_task(self, session: genai.LiveSession):
476
+ async def _send_task(self, session: AsyncSession):
469
477
  try:
470
478
  async for msg in self._msg_ch:
471
479
  async with self._session_lock:
@@ -485,7 +493,7 @@ class RealtimeSession(llm.RealtimeSession):
485
493
  finally:
486
494
  logger.debug("send task finished.")
487
495
 
488
- async def _recv_task(self, session: genai.LiveSession):
496
+ async def _recv_task(self, session: AsyncSession):
489
497
  try:
490
498
  while True:
491
499
  async with self._session_lock:
@@ -501,6 +509,15 @@ class RealtimeSession(llm.RealtimeSession):
501
509
  ):
502
510
  self._start_new_generation()
503
511
 
512
+ if response.session_resumption_update:
513
+ if (
514
+ response.session_resumption_update.resumable
515
+ and response.session_resumption_update.new_handle
516
+ ):
517
+ self._session_resumption_handle = (
518
+ response.session_resumption_update.new_handle
519
+ )
520
+
504
521
  if response.server_content:
505
522
  self._handle_server_content(response.server_content)
506
523
  if response.tool_call:
@@ -548,11 +565,13 @@ class RealtimeSession(llm.RealtimeSession):
548
565
  speech_config=SpeechConfig(
549
566
  voice_config=VoiceConfig(
550
567
  prebuilt_voice_config=PrebuiltVoiceConfig(voice_name=self._opts.voice)
551
- )
568
+ ),
569
+ language_code=self._opts.language if is_given(self._opts.language) else None,
552
570
  ),
553
571
  tools=[Tool(function_declarations=self._gemini_declarations)],
554
572
  input_audio_transcription=self._opts.input_audio_transcription,
555
573
  output_audio_transcription=self._opts.output_audio_transcription,
574
+ session_resumption=SessionResumptionConfig(handle=self._session_resumption_handle),
556
575
  )
557
576
 
558
577
  def _start_new_generation(self):
@@ -105,7 +105,7 @@ class TTS(tts.TTS):
105
105
  self._opts = _TTSOptions(
106
106
  voice=voice_params,
107
107
  audio_config=texttospeech.AudioConfig(
108
- audio_encoding=texttospeech.AudioEncoding.OGG_OPUS,
108
+ audio_encoding=texttospeech.AudioEncoding.PCM,
109
109
  sample_rate_hertz=sample_rate,
110
110
  pitch=pitch,
111
111
  effects_profile_id=effects_profile_id,
@@ -132,11 +132,11 @@ class TTS(tts.TTS):
132
132
  """ # noqa: E501
133
133
  params = {}
134
134
  if is_given(language):
135
- params["language"] = language
135
+ params["language_code"] = str(language)
136
136
  if is_given(gender):
137
- params["gender"] = gender
137
+ params["ssml_gender"] = _gender_from_str(str(gender))
138
138
  if is_given(voice_name):
139
- params["voice_name"] = voice_name
139
+ params["name"] = voice_name
140
140
 
141
141
  if params:
142
142
  self._opts.voice = texttospeech.VoiceSelectionParams(**params)
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- __version__ = "1.0.17"
15
+ __version__ = "1.0.18"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: livekit-plugins-google
3
- Version: 1.0.17
3
+ Version: 1.0.18
4
4
  Summary: Agent Framework plugin for services from Google Cloud
5
5
  Project-URL: Documentation, https://docs.livekit.io
6
6
  Project-URL: Website, https://livekit.io/
@@ -21,8 +21,8 @@ Requires-Python: >=3.9.0
21
21
  Requires-Dist: google-auth<3,>=2
22
22
  Requires-Dist: google-cloud-speech<3,>=2
23
23
  Requires-Dist: google-cloud-texttospeech<3,>=2
24
- Requires-Dist: google-genai>=1.11.0
25
- Requires-Dist: livekit-agents>=1.0.17
24
+ Requires-Dist: google-genai>=1.12.1
25
+ Requires-Dist: livekit-agents>=1.0.18
26
26
  Description-Content-Type: text/markdown
27
27
 
28
28
  # LiveKit Plugins Google
@@ -4,13 +4,13 @@ livekit/plugins/google/log.py,sha256=GI3YWN5YzrafnUccljzPRS_ZALkMNk1i21IRnTl2vNA
4
4
  livekit/plugins/google/models.py,sha256=SGjAumdDK97NNLwMFcqZdKR68f1NoGB2Rk1UP2-imG0,1457
5
5
  livekit/plugins/google/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  livekit/plugins/google/stt.py,sha256=AG_lh2fuuduJi0jFbA_QKFXLJ6NUdF1W_FfkLUJML_Q,22413
7
- livekit/plugins/google/tts.py,sha256=xhINokqY8UutXn85N-cbzq68eptbM6TTtIXmLktE_RM,9004
7
+ livekit/plugins/google/tts.py,sha256=fmQwW9a1kPsEsrTvIo8fqw479RxWEx0SIc3oTVaj41U,9031
8
8
  livekit/plugins/google/utils.py,sha256=TjjTwMbdJdxr3bZjUXxs-J_fipTTM00goW2-d9KWX6w,9582
9
- livekit/plugins/google/version.py,sha256=GOfJB-DKZur-i3hrjFbzgpC2NHE96dnWhGLziW1e0_E,601
9
+ livekit/plugins/google/version.py,sha256=cnPu9FVKZV9tFmmz7lEvftrO3B_nWJVFghi3j6UcJLs,601
10
10
  livekit/plugins/google/beta/__init__.py,sha256=AxRYc7NGG62Tv1MmcZVCDHNvlhbC86hM-_yP01Qb28k,47
11
11
  livekit/plugins/google/beta/realtime/__init__.py,sha256=_fW2NMN22F-hnQ4xAJ_g5lPbR7CvM_xXzSWlUQY-E-U,188
12
12
  livekit/plugins/google/beta/realtime/api_proto.py,sha256=Fyrejs3SG0EjOPCCFLEnWXKEUxCff47PMWk2VsKJm5E,594
13
- livekit/plugins/google/beta/realtime/realtime_api.py,sha256=2_nPBvPttVudoQswhf19ieJ6wxvHquGJgALJ09afQms,29873
14
- livekit_plugins_google-1.0.17.dist-info/METADATA,sha256=cKeNSFwiM2A-MJeNA6zNeX7ioqbvkEZO3aFfR8Run2c,3492
15
- livekit_plugins_google-1.0.17.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- livekit_plugins_google-1.0.17.dist-info/RECORD,,
13
+ livekit/plugins/google/beta/realtime/realtime_api.py,sha256=sXp2oHnTlHrAp5wFmcXj0bRtQKixBYedfbufcbjVHxk,30897
14
+ livekit_plugins_google-1.0.18.dist-info/METADATA,sha256=Vqt0FoqibcKzX_jFXlyFkn-mT7iPC16JlH61VS0fbuw,3492
15
+ livekit_plugins_google-1.0.18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ livekit_plugins_google-1.0.18.dist-info/RECORD,,