mirror of
https://github.com/HumanAIGC-Engineering/gradio-webrtc.git
synced 2026-02-04 17:39:23 +08:00
Set border radius (#84)
Co-authored-by: Freddy Boulton <freddyboulton@hf-freddy.local>
This commit is contained in:
@@ -42,6 +42,8 @@ class UIArgs(TypedDict):
|
||||
"""Color of the icon button. Default is var(--color-accent) of the demo theme."""
|
||||
pulse_color: NotRequired[str]
|
||||
"""Color of the pulse animation. Default is var(--color-accent) of the demo theme."""
|
||||
icon_radius: NotRequired[int]
|
||||
"""Border radius of the icon button expressed as a percentage of the button size. Default is 50%."""
|
||||
|
||||
|
||||
class Stream(WebRTCConnectionMixin):
|
||||
@@ -322,6 +324,7 @@ class Stream(WebRTCConnectionMixin):
|
||||
icon=ui_args.get("icon"),
|
||||
icon_button_color=ui_args.get("icon_button_color"),
|
||||
pulse_color=ui_args.get("pulse_color"),
|
||||
icon_radius=ui_args.get("icon_radius"),
|
||||
)
|
||||
for component in additional_output_components:
|
||||
if component not in same_components:
|
||||
@@ -358,6 +361,10 @@ class Stream(WebRTCConnectionMixin):
|
||||
rtc_configuration=self.rtc_configuration,
|
||||
mode="send-receive",
|
||||
modality="audio",
|
||||
icon=ui_args.get("icon"),
|
||||
icon_button_color=ui_args.get("icon_button_color"),
|
||||
pulse_color=ui_args.get("pulse_color"),
|
||||
icon_radius=ui_args.get("icon_radius"),
|
||||
)
|
||||
for component in additional_input_components:
|
||||
if component not in same_components:
|
||||
@@ -400,6 +407,7 @@ class Stream(WebRTCConnectionMixin):
|
||||
icon=ui_args.get("icon"),
|
||||
icon_button_color=ui_args.get("icon_button_color"),
|
||||
pulse_color=ui_args.get("pulse_color"),
|
||||
icon_radius=ui_args.get("icon_radius"),
|
||||
)
|
||||
for component in additional_input_components:
|
||||
if component not in same_components:
|
||||
@@ -443,6 +451,7 @@ class Stream(WebRTCConnectionMixin):
|
||||
icon=ui_args.get("icon"),
|
||||
icon_button_color=ui_args.get("icon_button_color"),
|
||||
pulse_color=ui_args.get("pulse_color"),
|
||||
icon_radius=ui_args.get("icon_radius"),
|
||||
)
|
||||
for component in additional_input_components:
|
||||
if component not in same_components:
|
||||
@@ -552,6 +561,7 @@ class Stream(WebRTCConnectionMixin):
|
||||
port: int = 8000,
|
||||
**kwargs,
|
||||
):
|
||||
import atexit
|
||||
import secrets
|
||||
import threading
|
||||
import time
|
||||
@@ -563,7 +573,6 @@ class Stream(WebRTCConnectionMixin):
|
||||
from gradio.networking import setup_tunnel
|
||||
from gradio.tunneling import CURRENT_TUNNELS
|
||||
from huggingface_hub import get_token
|
||||
import atexit
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import asyncio
|
||||
import fractions
|
||||
import functools
|
||||
import inspect
|
||||
import io
|
||||
import json
|
||||
import logging
|
||||
import tempfile
|
||||
import traceback
|
||||
from contextvars import ContextVar
|
||||
from typing import Any, Callable, Literal, Protocol, TypedDict, cast
|
||||
import functools
|
||||
import traceback
|
||||
import inspect
|
||||
|
||||
import av
|
||||
import numpy as np
|
||||
from numpy.typing import NDArray
|
||||
|
||||
@@ -87,6 +87,7 @@ class WebRTC(Component, WebRTCConnectionMixin):
|
||||
icon: str | None = None,
|
||||
icon_button_color: str | None = None,
|
||||
pulse_color: str | None = None,
|
||||
icon_radius: int | None = None,
|
||||
button_labels: dict | None = None,
|
||||
):
|
||||
"""
|
||||
@@ -119,6 +120,7 @@ class WebRTC(Component, WebRTCConnectionMixin):
|
||||
icon_button_color: Color of the icon button. Default is var(--color-accent) of the demo theme.
|
||||
pulse_color: Color of the pulse animation. Default is var(--color-accent) of the demo theme.
|
||||
button_labels: Text to display on the audio or video start, stop, waiting buttons. Dict with keys "start", "stop", "waiting" mapping to the text to display on the buttons.
|
||||
icon_radius: Border radius of the icon button expressed as a percentage of the button size. Default is 50%
|
||||
"""
|
||||
self.time_limit = time_limit
|
||||
self.height = height
|
||||
@@ -129,6 +131,7 @@ class WebRTC(Component, WebRTCConnectionMixin):
|
||||
self.mode = mode
|
||||
self.modality = modality
|
||||
self.icon_button_color = icon_button_color
|
||||
self.icon_radius = icon_radius
|
||||
self.pulse_color = pulse_color
|
||||
self.rtp_params = rtp_params or {}
|
||||
self.button_labels = {
|
||||
|
||||
@@ -149,14 +149,14 @@ class WebRTCConnectionMixin:
|
||||
|
||||
if isinstance(self.event_handler, StreamHandlerBase):
|
||||
handler = self.event_handler.copy()
|
||||
handler.emit = webrtc_error_handler(handler.emit)
|
||||
handler.receive = webrtc_error_handler(handler.receive)
|
||||
handler.start_up = webrtc_error_handler(handler.start_up)
|
||||
handler.shutdown = webrtc_error_handler(handler.shutdown)
|
||||
handler.emit = webrtc_error_handler(handler.emit) # type: ignore
|
||||
handler.receive = webrtc_error_handler(handler.receive) # type: ignore
|
||||
handler.start_up = webrtc_error_handler(handler.start_up) # type: ignore
|
||||
handler.shutdown = webrtc_error_handler(handler.shutdown) # type: ignore
|
||||
if hasattr(handler, "video_receive"):
|
||||
handler.video_receive = webrtc_error_handler(handler.video_receive)
|
||||
handler.video_receive = webrtc_error_handler(handler.video_receive) # type: ignore
|
||||
if hasattr(handler, "video_emit"):
|
||||
handler.video_emit = webrtc_error_handler(handler.video_emit)
|
||||
handler.video_emit = webrtc_error_handler(handler.video_emit) # type: ignore
|
||||
else:
|
||||
handler = webrtc_error_handler(cast(Callable, self.event_handler))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user