mirror of
https://github.com/HumanAIGC-Engineering/gradio-webrtc.git
synced 2026-02-05 18:09:23 +08:00
More tweaks (#71)
* tweaks * Make icon colors match --------- Co-authored-by: Freddy Boulton <freddyboulton@hf-freddy.local>
This commit is contained in:
@@ -346,7 +346,7 @@ class Stream(WebRTCConnectionMixin):
|
|||||||
gr.HTML(
|
gr.HTML(
|
||||||
f"""
|
f"""
|
||||||
<h1 style='text-align: center'>
|
<h1 style='text-align: center'>
|
||||||
{ui_args.get("title", "Audio Streaming (Powered by WebRTC ⚡️)")}
|
{ui_args.get("title", "Audio Streaming (Powered by FastRTC ⚡️)")}
|
||||||
</h1>
|
</h1>
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
@@ -385,7 +385,7 @@ class Stream(WebRTCConnectionMixin):
|
|||||||
gr.HTML(
|
gr.HTML(
|
||||||
f"""
|
f"""
|
||||||
<h1 style='text-align: center'>
|
<h1 style='text-align: center'>
|
||||||
{ui_args.get("title", "Audio Streaming (Powered by WebRTC ⚡️)")}
|
{ui_args.get("title", "Audio Streaming (Powered by FastRTC ⚡️)")}
|
||||||
</h1>
|
</h1>
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
@@ -428,7 +428,7 @@ class Stream(WebRTCConnectionMixin):
|
|||||||
gr.HTML(
|
gr.HTML(
|
||||||
f"""
|
f"""
|
||||||
<h1 style='text-align: center'>
|
<h1 style='text-align: center'>
|
||||||
{ui_args.get("title", "Audio Streaming (Powered by WebRTC ⚡️)")}
|
{ui_args.get("title", "Audio Video Streaming (Powered by FastRTC ⚡️)")}
|
||||||
</h1>
|
</h1>
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
@@ -563,6 +563,7 @@ class Stream(WebRTCConnectionMixin):
|
|||||||
from gradio.networking import setup_tunnel
|
from gradio.networking import setup_tunnel
|
||||||
from gradio.tunneling import CURRENT_TUNNELS
|
from gradio.tunneling import CURRENT_TUNNELS
|
||||||
from huggingface_hub import get_token
|
from huggingface_hub import get_token
|
||||||
|
import atexit
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
@@ -618,6 +619,16 @@ class Stream(WebRTCConnectionMixin):
|
|||||||
)
|
)
|
||||||
+ " for information on making your handler compatible with phone usage."
|
+ " for information on making your handler compatible with phone usage."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def unregister():
|
||||||
|
httpx.post(
|
||||||
|
URL + "/unregister",
|
||||||
|
json={"url": host, "code": code},
|
||||||
|
headers={"Authorization": token or get_token() or ""},
|
||||||
|
)
|
||||||
|
|
||||||
|
atexit.register(unregister)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
@@ -626,11 +637,7 @@ class Stream(WebRTCConnectionMixin):
|
|||||||
click.style("INFO", fg="green")
|
click.style("INFO", fg="green")
|
||||||
+ ":\t Keyboard interruption in main thread... closing server."
|
+ ":\t Keyboard interruption in main thread... closing server."
|
||||||
)
|
)
|
||||||
r = httpx.post(
|
unregister()
|
||||||
URL + "/unregister",
|
|
||||||
json={"url": host, "code": code},
|
|
||||||
headers={"Authorization": token or get_token() or ""},
|
|
||||||
)
|
|
||||||
t.join(timeout=5)
|
t.join(timeout=5)
|
||||||
for tunnel in CURRENT_TUNNELS:
|
for tunnel in CURRENT_TUNNELS:
|
||||||
tunnel.kill()
|
tunnel.kill()
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ The Real-Time Communication Library for Python.
|
|||||||
|
|
||||||
Turn any python function into a real-time audio and video stream over WebRTC or WebSockets.
|
Turn any python function into a real-time audio and video stream over WebRTC or WebSockets.
|
||||||
|
|
||||||
<video src="https://github.com/user-attachments/assets/6fb7f4fe-c5b2-48f3-88ff-f563611812ec" controls></video>
|
<video src="https://github.com/user-attachments/assets/a297aa1e-ff42-448c-a58c-389b0a575d4d" controls></video>
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -25,10 +25,10 @@ Turn any python function into a real-time audio and video stream over WebRTC or
|
|||||||
pip install fastrtc
|
pip install fastrtc
|
||||||
```
|
```
|
||||||
|
|
||||||
to use built-in pause detection (see [ReplyOnPause](userguide/audio/#reply-on-pause)), and text to speech (see [Text To Speech](userguide/audio/#text-to-speech)), install the `vad` and `tts` extras:
|
to use built-in pause detection (see [ReplyOnPause](userguide/audio/#reply-on-pause)), speech-to-text (see [Speech To Text](userguide/audio/#speech-to-text)), and text to speech (see [Text To Speech](userguide/audio/#text-to-speech)), install the `vad`, `stt`, and `tts` extras:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install fastrtc[vad, tts]
|
pip install fastrtc[vad, stt, tts]
|
||||||
```
|
```
|
||||||
|
|
||||||
## Quickstart
|
## Quickstart
|
||||||
|
|||||||
@@ -304,7 +304,11 @@
|
|||||||
</div>
|
</div>
|
||||||
{:else if stream_state === "open"}
|
{:else if stream_state === "open"}
|
||||||
<div class="icon-with-text">
|
<div class="icon-with-text">
|
||||||
<div class="icon color-primary" title="stop recording">
|
<div
|
||||||
|
class="icon"
|
||||||
|
title="stop recording"
|
||||||
|
style={`fill: ${icon_button_color}; stroke: ${icon_button_color}; color: ${icon_button_color};`}
|
||||||
|
>
|
||||||
<PulsingIcon
|
<PulsingIcon
|
||||||
audio_source_callback={() => stream}
|
audio_source_callback={() => stream}
|
||||||
stream_state={"open"}
|
stream_state={"open"}
|
||||||
|
|||||||
Reference in New Issue
Block a user