Live interfaces
Make your interface automatically recalculate whenever user input changes by settinglive=True:
Notice there’s no submit button - the interface resubmits automatically on change.
How live mode works
Whenlive=True:
- The interface listens for changes on all input components
- When any input changes, the function automatically runs
- Outputs update immediately without clicking a button
- The submit button is hidden
- Real-time calculators and converters
- Interactive data visualizations
- Live image/audio filters
- Instant feedback applications
Streaming components
Some components support a “streaming” mode that continuously sends data to the backend:Audiocomponent in microphone modeImagecomponent in webcam mode
Streaming vs live mode
There’s an important difference between regular and streaming components in live mode:streaming=True, the function runs continuously during recording, not just when recording stops.
Streaming webcam input
Here’s an example of streaming images from the webcam:- Captures frames from the webcam
- Sends them to the
flipfunction - Displays the flipped output in real-time
Streaming output
Streaming can also be used in output components. Agr.Audio(streaming=True) output can take a stream of audio data yielded piece-wise by a generator function:
Stream configuration
You can configure streaming behavior with these Interface parameters:time_limit
time_limit
Maximum time (in seconds) for streaming to run:Default is 30 seconds.
stream_every
stream_every
Latency (in seconds) between stream chunks sent to backend:Default is 0.5 seconds.
These parameters only apply when:
- The interface is in live mode (
live=True) - Input components have
streaming=True
Use cases
Real-time speech recognition
Stream audio from microphone and transcribe in real-time
Live video filters
Apply filters to webcam feed with immediate preview
Interactive calculators
Show results as users type or adjust sliders
Audio synthesis
Generate and stream audio output progressively
Performance considerations
When not to use live mode
Avoid live mode when:- Your function is computationally expensive
- You want users to review inputs before submitting
- Processing takes significant time
- You need to batch requests for efficiency
Advanced streaming examples
For detailed examples of streaming in action, see:Next steps
Interface class
Learn more about the Interface class
Interface types
Explore the 4 different types of interfaces