Skip to main content

A real-time Gemini API streaming library with FastAPI integration

Project description

🎙️ Gemini Live Voice Only Python

Gemini Live Voice Only is a real-time streaming library that integrates the Gemini API with FastAPI and WebRTC using fastrtc. This package enables developers to build applications that process audio streams in real time—ideal for tasks such as voice-based ID matching. 🔊

✨ Features

  • 🚀 Real-time Audio Streaming: Seamlessly stream audio data via FastAPI and WebRTC.
  • 🔍 Gemini API Integration: Leverage the Gemini API's live voice processing capabilities.
  • ⚙️ Customizable Configuration: Set your API key, system prompt, and voice name at initialization.
  • 🌍 Flexible CORS Setup: Configure CORS settings to suit your deployment needs.
  • 🛠️ Easy-to-Use API: Quickly create and run your streaming server with minimal setup.

📥 Installation

Install the package from PyPI:

pip install gemini_live_voice_only

Or install it in editable mode from the source repository:

git clone <repository_url>
cd gemini_live_voice_only
pip install -e .

🚀 Usage

Here's a quick example to get you started:

from gemini_live_voice_only import create_gemini_stream
import uvicorn

# 🎛️ Configuration parameters
API_KEY = "YOUR_API_KEY"
SYSTEM_PROMPT = (
    "You are a specialized ID matching tool. Compare input IDs with the reference ID 'RBTL24CB067' "
    "and output only the matching percentage."
)
VOICE_NAME = "Puck"

# 🎤 Create the FastAPI app with customizable CORS settings
app = create_gemini_stream(
    api_key=API_KEY,
    system_prompt=SYSTEM_PROMPT,
    voice_name=VOICE_NAME,
    cors_origins=["https://yourdomain.com"],  # specify allowed origins
    cors_allow_credentials=True,
    cors_allow_methods=["*"],
    cors_allow_headers=["*"],
)

if __name__ == "__main__":
    uvicorn.run(app, host="127.0.0.1", port=7860, reload=True)

⚙️ Configuration Options

When using the create_gemini_stream function, you can configure:

  • 🔑 API Key, System Prompt, and Voice Name: Required for setting up the Gemini API connection.
  • 🌐 ICE Servers: Customize the ICE server list for WebRTC connections if needed.
  • 🔄 CORS Settings: Configure cors_origins, cors_allow_credentials, cors_allow_methods, and cors_allow_headers for cross-origin resource sharing.
  • 🎶 Audio Stream Parameters: Adjust expected_layout, output_sample_rate, output_frame_size, and input_sample_rate based on your audio processing needs.
  • Concurrency & Time Limits: Modify concurrency_limit and time_limit to suit your application's requirements.

🤝 Contributing

Contributions are welcome! 🎉 If you have suggestions, bug reports, or feature requests, please open an issue or submit a pull request. 🚀

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gemini_live_voice_only-0.1.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gemini_live_voice_only-0.1.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file gemini_live_voice_only-0.1.1.tar.gz.

File metadata

  • Download URL: gemini_live_voice_only-0.1.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for gemini_live_voice_only-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ea516a63d0da8364c152b011485e309cc5c6d112081b9d8b4819513e27a239f3
MD5 dd5995c2650f47b37015205e882c7c43
BLAKE2b-256 feec425f977d9f772badebcfe6da71d9a1ccaea9131d0ca849c54a5cc5951bcc

See more details on using hashes here.

File details

Details for the file gemini_live_voice_only-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gemini_live_voice_only-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 232092e2459f65112fc616909adf5e2e59cd2051a703b0ad89dc77741cfa4973
MD5 0d467000697c4a868dc3a983344d7df2
BLAKE2b-256 59592bb50a366bd2195ef31c232e482b09dbab392805e6cb878546a1ec51ed19

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page