Fastrtc

    Fastrtc

    Tech
    Framework
    Open Source

    Python library for real-time audio and video streaming with WebRTC.

    Fastrtc banner

    About Fastrtc

    FastRTC: Real-Time Communication Library for Python

    FastRTC is an open-source Python library that transforms any Python function into a real-time audio or video stream using WebRTC or WebSockets. Designed for flexibility and rapid prototyping, FastRTC makes it easy to build, test, and deploy real-time communication applications, including AI voice and video agents, directly from your Python code.

    Key Features

    • Real-Time Audio and Video Streaming: Stream audio or video in real time over WebRTC or WebSockets by simply wrapping your Python functions.

    • Automatic Voice Detection and Turn-Taking: Built-in pause detection and voice activity detection, so you can focus on your application logic.

    • Integrated Speech-to-Text and Text-to-Speech: Optional extras for seamless speech recognition and synthesis within your streams.

    • Instant UI with Gradio: Launch a built-in, WebRTC-enabled UI for easy testing and sharing using .ui.launch().

    • WebRTC and WebSocket Endpoints: Easily mount your stream on a FastAPI app to provide endpoints for custom frontends.

    • Temporary Telephone Numbers: Use the .fastphone() method to get a free, temporary phone number for calling into your stream (Hugging Face token required).

    • Customizable and Extensible: Easily integrate with production systems, extend with your own logic, and connect to external AI models or APIs.

    • Video and Image Processing: Supports real-time video and image streams for applications like object detection and video manipulation.

    How It Works

    1. Define a Handler: Write a Python function to process audio, video, or images.

    2. Create a Stream: Wrap your handler with the Stream class, specifying the modality (audio or video) and mode.

    3. Choose an Interface:

      • Launch a built-in UI for rapid prototyping.

      • Mount on a FastAPI app for production use.

      • Enable phone call integration for voice streams.

    4. Add Extras: Optionally install and use built-in speech-to-text, text-to-speech, or voice activity detection modules.

    Example Use Cases

    • Voice and video chatbots

    • Real-time AI voice assistants

    • Interactive video processing (e.g., object detection, video filters)

    • Voice-enabled telephony applications

    • Custom audio or video pipelines for research and prototyping

    Getting Started

    FastRTC is ideal for developers and researchers who want to rapidly build, test, and deploy real-time audio and video applications in Python, with minimal setup and maximum flexibility.