# FastRTC

> The real-time communication library for Python that turns any function into audio and video streams over WebRTC or WebSockets.

FastRTC is a Python library that enables developers to transform any Python function into real-time audio and video streams over WebRTC or WebSockets. Built by the Gradio team, it provides a simple yet powerful interface for creating voice-enabled applications, video processing pipelines, and interactive communication tools with minimal code.

The library offers three main deployment methods: a built-in UI for testing and sharing streams, a fastphone feature for temporary phone number access, and FastAPI integration for production systems.

- **Stream Class** provides the core abstraction for handling real-time communication, supporting audio, video, and combined audio-video modalities with send-receive or receive-only modes.

- **Automatic Voice Detection** includes built-in pause detection and turn-taking capabilities through the ReplyOnPause handler, allowing developers to focus on response logic rather than audio processing mechanics.

- **Built-in UI** launches a Gradio-powered interface with `.ui.launch()` for rapid prototyping and testing of streams without building custom frontends.

- **WebRTC and WebSocket Support** enables mounting streams on FastAPI applications to expose endpoints for custom frontend integrations with full real-time communication capabilities.

- **Telephone Integration** offers the `.fastphone()` method to obtain free temporary phone numbers for calling into streams, requiring only a Hugging Face token.

- **Speech-to-Text and Text-to-Speech** plugins are available through optional extras (`vad`, `stt`, `tts`), enabling voice-to-voice AI applications with LLM integration.

- **Video Processing** supports real-time video manipulation including object detection, image transformations, and webcam streaming with customizable handlers.

- **Plugin Ecosystem** provides galleries for text-to-speech, speech-to-text, and turn-taking models, making it easy to swap components for different use cases.

To get started, install with `pip install fastrtc` and optionally add extras for voice features. Create a Stream with a handler function, then launch the UI or mount on FastAPI. The library handles WebRTC negotiation, audio chunking, and stream management automatically.

## Features
- Real-time audio streaming over WebRTC
- Real-time video streaming over WebRTC
- WebSocket support
- Automatic voice detection and turn-taking
- Built-in Gradio UI
- FastAPI integration
- Telephone integration with temporary phone numbers
- Speech-to-text support
- Text-to-speech support
- Pause detection handlers
- Object detection support
- Customizable track constraints
- Echo cancellation configuration
- Plugin ecosystem for TTS/STT models

## Integrations
Gradio, FastAPI, Hugging Face, OpenAI, SambaNova, YOLOv10

## Platforms
API, DEVELOPER_SDK

## Pricing
Open Source

## Version
0.0.34

## Links
- Website: https://fastrtc.org
- Documentation: https://fastrtc.org/userguide/streams/
- Repository: https://github.com/gradio-app/fastrtc
- EveryDev.ai: https://www.everydev.ai/tools/fastrtc
