LiveKit Google Cloud Plugins

1.5.2 · active · verified Tue Apr 14

livekit-plugins-google provides Speech-to-Text (STT) and Text-to-Speech (TTS) capabilities using Google Cloud services for the LiveKit Agent Framework. It enables agents to transcribe audio and generate spoken responses using Google's robust AI models. The current version is 1.5.2, aligning with the `livekit-agents` monorepo's release cadence, which typically sees frequent updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the Google STT and TTS plugins. It assumes your environment is configured for Google Cloud authentication (e.g., via `GOOGLE_APPLICATION_CREDENTIALS` environment variable or `gcloud auth application-default login`). In a real LiveKit agent, these plugins would be integrated into an Agent instance to process live audio streams.

import asyncio
from livekit.plugins.google import STT, TTS

async def main():
    # Google Cloud authentication is typically handled via environment variables
    # such as GOOGLE_APPLICATION_CREDENTIALS or gcloud CLI configuration.
    # Ensure your environment is set up for Google Cloud authentication.

    # Instantiate Google Speech-to-Text
    try:
        google_stt = STT()
        print(f"Google STT initialized: {google_stt.name}")

        # Instantiate Google Text-to-Speech
        google_tts = TTS()
        print(f"Google TTS initialized: {google_tts.name}")

        # Example of using TTS (simplified, in a real agent context it handles audio streams)
        # Note: This quickstart primarily demonstrates initialization.
        # Actual usage involves passing audio frames to STT and receiving audio frames from TTS.
        text_to_speak = "Hello, this is a test from LiveKit Google TTS."
        # In a real scenario, this would generate an audio iterator
        # audio_iterator = await google_tts.synthesize(text_to_speak)
        print(f"Would synthesize: '{text_to_speak}'")

    except Exception as e:
        print(f"Failed to initialize Google plugins. Ensure Google Cloud SDK is configured and credentials are set: {e}")

if __name__ == "__main__":
    asyncio.run(main())

view raw JSON →