diff --git a/README.md b/README.md
index f6a58ad..2dab0d6 100644
--- a/README.md
+++ b/README.md
@@ -9,10 +9,15 @@ pinned: false
app_file: space.py
---
-# `gradio_webrtc`
-
+
| name | -type | -default | -description | -
|---|---|---|---|
value |
-+## Streaming Video from the User Webcam to the Server and Back ```python -None +import gradio as gr +from gradio_webrtc import WebRTC +import cv2 + +def generation(): + url = "https://download.tsi.telecom-paristech.fr/gpac/dataset/dash/uhd/mux_sources/hevcds_720p30_2M.mp4" + cap = cv2.VideoCapture(url) + iterating = True + while iterating: + iterating, frame = cap.read() + yield frame + +with gr.Blocks() as demo: + output_video = WebRTC(label="Video Stream", mode="receive", modality="video") + button = gr.Button("Start", variant="primary") + output_video.stream( + fn=generation, inputs=None, outputs=[output_video], + trigger=button.click + ) + +if __name__ == "__main__": + demo.launch() ``` - | -None |
-path or URL for the default value that WebRTC component is going to take. Can also be a tuple consisting of (video filepath, subtitle filepath). If a subtitle file is provided, it should be of type .srt or .vtt. Or can be callable, in which case the function will be called whenever the app loads to set the initial value of the component. | -
height |
-+## Streaming Audio from the Server to the Client ```python -int | str | None +import gradio as gr +from pydub import AudioSegment + +def generation(num_steps): + for _ in range(num_steps): + segment = AudioSegment.from_file("/Users/freddy/sources/gradio/demo/audio_debugger/cantina.wav") + yield (segment.frame_rate, np.array(segment.get_array_of_samples()).reshape(1, -1)) + +with gr.Blocks() as demo: + audio = WebRTC(label="Stream", mode="receive", modality="audio") + num_steps = gr.Slider( + label="Number of Steps", + minimum=1, + maximum=10, + step=1, + value=5, + ) + button = gr.Button("Generate") + + audio.stream( + fn=generation, inputs=[num_steps], outputs=[audio], + trigger=button.click + ) ``` - | -None |
-The height of the component, specified in pixels if a number is passed, or in CSS units if a string is passed. This has no effect on the preprocessed video file, but will affect the displayed video. | -
width |
-+## Deployment + +When deploying in a cloud environment (like Hugging Face Spaces, EC2, etc), you need to set up a TURN server to relay the WebRTC traffic. +The easiest way to do this is to use a service like Twilio. ```python -int | str | None -``` +from twilio.rest import Client +import os - | -None |
-The width of the component, specified in pixels if a number is passed, or in CSS units if a string is passed. This has no effect on the preprocessed video file, but will affect the displayed video. | -
label |
-+client = Client(account_sid, auth_token) -```python -str | None -``` +token = client.tokens.create() - | -None |
-the label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to. | -
every |
-- -```python -Timer | float | None -``` - - | -None |
-continously calls `value` to recalculate it if `value` is a function (has no effect otherwise). Can provide a Timer whose tick resets `value`, or a float that provides the regular interval for the reset Timer. | -
inputs |
-- -```python -Component | Sequence[Component] | set[Component] | None -``` - - | -None |
-components that are used as inputs to calculate `value` if `value` is a function (has no effect otherwise). `value` is recalculated any time the inputs change. | -
show_label |
-- -```python -bool | None -``` - - | -None |
-if True, will display label. | -
container |
-- -```python -bool -``` - - | -True |
-if True, will place the component in a container - providing some extra padding around the border. | -
scale |
-- -```python -int | None -``` - - | -None |
-relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True. | -
min_width |
-- -```python -int -``` - - | -160 |
-minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first. | -
interactive |
-- -```python -bool | None -``` - - | -None |
-if True, will allow users to upload a video; if False, can only be used to display videos. If not provided, this is inferred based on whether the component is used as an input or output. | -
visible |
-- -```python -bool -``` - - | -True |
-if False, component will be hidden. | -
elem_id |
-- -```python -str | None -``` - - | -None |
-an optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles. | -
elem_classes |
-- -```python -list[str] | str | None -``` - - | -None |
-an optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles. | -
render |
-- -```python -bool -``` - - | -True |
-if False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later. | -
key |
-- -```python -int | str | None -``` - - | -None |
-if assigned, will be used to assume identity across a re-render. Components that have the same key across a re-render will have their value preserved. | -
mirror_webcam |
-- -```python -bool -``` - - | -True |
-if True webcam will be mirrored. Default is True. | -
rtc_configuration |
-- -```python -dict[str, Any] | None -``` - - | -None |
-None | -
time_limit |
-- -```python -float | None -``` - - | -None |
-None | -
mode |
-- -```python -Literal["send-receive", "receive"] -``` - - | -"send-receive" |
-None | -
modality |
-- -```python -Literal["video", "audio"] -``` - - | -"video" |
-None | -