how to use google beta tts To use it is basically ...
# ask-ai
m
how to use google beta tts To use it is basically this:
Copy code
from livekit.plugins.google.beta import gemini_tts  
  
tts = gemini_tts.TTS(model="gemini-2.5-pro-preview-tts")
t
Thanks for reaching out, Ayse. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! If you want to use Google Beta TTS in LiveKit, here’s a simple guide to get you started: 1. Install the Plugin: First, make sure you have the LiveKit Google plugin installed by running:
pip install "livekit-agents[google]~=1.0"
2. Enable Services: Don’t forget to enable the Google Cloud Text-to-Speech API for your project — it’s essential! 3. Usage: Here’s a quick example to help you initialize and use Google Beta TTS:
Copy code
from livekit.plugins.google import beta

# Initialize the Google Beta TTS
tts = beta.TTS(
    model="gemini-2.5-flash-preview-tts",  # Pick a supported model
    voice_name="Kore",  # Choose a voice you like
    api_key="your-api-key",  # Add your API key or credentials here
    vertexai=True  # Optional: Use Vertex AI if you have it set up
)

# Use the TTS in an AgentSession
session = AgentSession(
    tts=tts,
    # You can add other settings like LLM and STT here
)
Quick rundown of key parameters:model: This tells the system which Google Beta model to use (like "gemini-2.5-flash-preview-tts"). • voice_name: Pick the voice for the speech (e.g., "Kore"). • api_key: Your Google API key to authenticate your requests. • vertexai: Set this to
True
if you’re using Vertex AI. Just a heads-up: make sure to enable the Gemini TTS services in your Google Cloud Console. For more info and details, check out the LiveKit Google plugin documentation. If you run into any questions, I’m here to help!
m
34.146499+0000"} {"message": "Unexpected error in entrypoint: module 'livekit.plugins.google.beta' has no attribute 'TTS'\nTraceback (most recent call last):\n File \"/Users/theatech/Desktop/mercedes-prompt/agent.py\", line 472, in entrypoint\n components = BaseAgentConfig.create_default_components(\n language=\"tr\", instructions=prompt, tools=agent_tools\n )\n File \"/Users/theatech/Desktop/mercedes-prompt/base_agent.py\", line 166, in create_default_components\n tts = cls.create_gemini_tts()\n File \"/Users/theatech/Desktop/mercedes-prompt/base_agent.py\", line 84, in create_gemini_tts\n return beta.TTS(\n ^^^^^^^^\nAttributeError: module 'livekit.plugins.google.beta' has no attribute 'TTS'", "level": "ERROR", "name": "outbound-arge-agent", "pid": 33845, "job_id": "AJ_nvnFqjw3GocX", "timestamp": "2025-08-12T133634.149747+00:00"} {"message": "process exiting", "level": "INFO", "name": "livekit.agents", "reason": "", "pid": 33845, "job_id": "AJ_nvnFqjw3GocX", "timestamp": "2025-08-12T133634.151238+00:00"}
t
Hey there! That error
module 'livekit.plugins.google.beta' has no attribute 'TTS'
pops up because the
TTS
class isn’t directly inside the
google.beta
module. Instead, you’ll want to use
GeminiTTS
to access the Gemini TTS features. Here’s a quick way to fix it: 1. Using Gemini TTS (Beta):
Copy code
from livekit.plugins.google.beta import GeminiTTS

# Initialize Gemini TTS
gemini_tts = GeminiTTS(
    model="gemini-2.5-flash-preview-tts",
    voice_name="Kore",
)
2. Using Google Cloud TTS (Stable):
Copy code
from livekit.plugins.google import TTS

# Initialize Google Cloud TTS
tts = TTS(
    gender="female",
    voice_name="en-US-Standard-H",
)
Just make sure you’re importing the right class depending on whether you’re working with the stable Google Cloud TTS or the beta Gemini TTS. If you hit any snags or want me to walk you through it, just let me know—I’m here to help!
m
7+00:00"} {"message": "AFC is enabled with max remote calls: 10.", "level": "INFO", "name": "google_genai.models", "pid": 34105, "job_id": "AJ_mN3QCk4waZUA", "timestamp": "2025-08-12T134016.842559+00:00"} {"message": "failed to synthesize speech, retrying in 0.1s\nTraceback (most recent call last):\n File \"/Users/theatech/Desktop/mercedes-prompt/menv/lib/python3.13/site-packages/livekit/plugins/google/beta/gemini_tts.py\", line 192, in _run\n response = await self._tts._client.aio.models.generate_content(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n ...<3 lines>...\n )\n ^\n File \"/Users/theatech/Desktop/mercedes-prompt/menv/lib/python3.13/site-packages/google/genai/models.py\", line 7810, in generate_content\n response = await self._generate_content(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n model=model, contents=contents, config=parsed_config\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File \"/Users/theatech/Desktop/mercedes-prompt/menv/lib/python3.13/site-packages/google/genai/models.py\", line 6657, in _generate_content\n response = await self._api_client.async_request(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n 'post', path, request_dict, http_options\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File \"/Users/theatech/Desktop/mercedes-prompt/menv/lib/python3.13/site-packages/google/genai/_api_client.py\", line 1296, in async_request\n result = await self._async_request(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\n http_request=http_request, http_options=http_options, stream=False\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File \"/Users/theatech/Desktop/mercedes-prompt/menv/lib/python3.13/site-packages/google/genai/_api_client.py\", line 1241, in _async_request\n return await self._async_retry( # type: ignore[no-any-return]\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n self._async_request_once, http_request, stream\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File \"/Users/theatech/Desktop/mercedes-prompt/menv/lib/python3.13/site-packages/tenacity/asyncio/__init__.py\", line 111, in __call__\n do = await self.iter(retry_state=retry_state)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/Users/theatech/Desktop/mercedes-prompt/menv/lib/python3.13/site-packages/tenacity/asyncio/__init__.py\", line 153, in iter\n result = await action(retry_state)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/Users/theatech/Desktop/mercedes-prompt/menv/lib/python3.13/site-packages/tenacity/_utils.py\", line 99, in inner\n return call(*args, **kwargs)\n File \"/Users/theatech/Desktop/mercedes-prompt/menv/lib/python3.13/site-packages/tenacity/__init__.py\", line 420, in exc_check\n raise retry_exc.reraise()\n ~~~~~~~~~~~~~~~~~^^\n File \"/Users/theatech/Desktop/mercedes-prompt/menv/lib/python3.13/site-packages/tenacity/__init__.py\", line 187, in reraise\n raise self.last_attempt.result()\n ~~~~~~~~~~~~~~~~~~~~~~~~^^\n File \"/opt/homebrew/Cellar/python@3.13/3.13.3_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py\", line 449, in result\n return self.__get_result()\n ~~~~~~~~~~~~~~~~~^^\n File \"/opt/homebrew/Cellar/python@3.13/3.13.3_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py\", line 401, in __get_result\n raise self._exception\n File \"/Users/theatech/Desktop/mercedes-prompt/menv/lib/python3.13/site-packages/tenacity/asyncio/__init__.py\", line 114, in __call__\n result = await fn(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/Users/theatech/Desktop/mercedes-prompt/menv/lib/python3.13/site-packages/google/genai/_api_client.py\", line 1182, in _async_request_once\n await errors.APIError.raise_for_async_response(response)\n File \"/Users/theatech/Desktop/mercedes-prompt/menv/lib/python3.13/site-packages/google/genai/errors.py\", line 156, in raise_for_async_response\n raise ClientError(status_code, response_json, response)\ngoogle.genai.errors.ClientError: 403 PERMISSION_DENIED. {'error': {'code': 403, 'message': \"Permission 'aiplatform.endpoints.predict' denied on resource '<//aiplatform.googleapis.com/projects/qfix-457011/locations/us-central1/publishers/google/models/gemini-2.5-flash-preview-tts>' (or it may not exist).\", 'status': 'PERMISSION_DENIED', 'details': [{'@type': 'type.googleapis.com/google.rpc.ErrorInfo', 'reason': 'IAM_PERMISSION_DENIED', 'domain': 'aiplatform.googleapis.com', 'metadata': {'permission': 'aiplatform.endpoints.predict', 'resource': 'projects/qfix-457011/locations/us-central1/publishers/google/models/gemini-2.5-flash-preview-tts'}}]}}\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File \"/Users/theatech/Desktop/mercedes-prompt/menv/lib/python3.13/site-packages/livekit/agents/tts/tts.py\", line 231, in _main_task\n await self._run(output_emitter)\n File \"/Users/theatech/Desktop/mercedes-prompt/menv/lib/python3.13/site-packages/livekit/plugins/google/beta/gemini_tts.py\", line 223, in _run\n raise APIStatusError(\n ...<4 lines>...\n ) from e\nlivekit.agents._exceptions.APIStatusError: gemini tts: client error (status_code=403, request_id=None, body=Permission 'aiplatform.endpoints.predict' denied on resource '<//aiplatform.googleapis.com/projects/qfix-457011/locations/us-central1/publishers/google/models/gemini-2.5-flash-preview-tts>' (or it may not exist). PERMISSION_DENIED, retryable=False)", "level": "WARNING", "name": "livekit.agents", "tts": "livekit.plugins.google.beta.gemini_tts.TTS", "attempt": 1, "streamed": false, "pid": 34105, "job_id": "AJ_mN3QCk4waZUA", "timestamp": "2025-08-12T134018.176177+00:00"}
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
m
{"message": "Unexpected error in entrypoint: module 'livekit.plugins.google.beta' has no attribute 'TTS'\nTraceback (most recent call last):\n File \"/Users/theatech/Desktop/mercedes-prompt/agent.py\", line 472, in entrypoint\n components = BaseAgentConfig.create_default_components(\n language=\"tr\", instructions=prompt, tools=agent_tools\n )\n File \"/Users/theatech/Desktop/mercedes-prompt/base_agent.py\", line 166, in create_default_components\n tts = cls.create_gemini_tts()\n File \"/Users/theatech/Desktop/mercedes-prompt/base_agent.py\", line 84, in create_gemini_tts\n return beta.TTS(\n ^^^^^^^^\nAttributeError: module 'livekit.plugins.google.beta' has no attribute 'TTS'", "level": "ERROR", "name": "outbound-arge-agent", "pid": 34439, "job_id": "AJ_Bnd82VzChYTz", "timestamp": "2025-08-12T134210.227711+00:00"} {"message": "process exiting", "level": "INFO", "name": "livekit.agents", "reason": "", "pid": 34439, "job_id": "AJ_Bnd82VzChYTz", "timestamp": "2025-08-12T134210.232297+00:00"}