mirror of
https://github.com/HumanAIGC-Engineering/gradio-webrtc.git
synced 2026-02-04 17:39: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(
|
||||
f"""
|
||||
<h1 style='text-align: center'>
|
||||
{ui_args.get("title", "Audio Streaming (Powered by WebRTC ⚡️)")}
|
||||
{ui_args.get("title", "Audio Streaming (Powered by FastRTC ⚡️)")}
|
||||
</h1>
|
||||
"""
|
||||
)
|
||||
@@ -385,7 +385,7 @@ class Stream(WebRTCConnectionMixin):
|
||||
gr.HTML(
|
||||
f"""
|
||||
<h1 style='text-align: center'>
|
||||
{ui_args.get("title", "Audio Streaming (Powered by WebRTC ⚡️)")}
|
||||
{ui_args.get("title", "Audio Streaming (Powered by FastRTC ⚡️)")}
|
||||
</h1>
|
||||
"""
|
||||
)
|
||||
@@ -428,7 +428,7 @@ class Stream(WebRTCConnectionMixin):
|
||||
gr.HTML(
|
||||
f"""
|
||||
<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>
|
||||
"""
|
||||
)
|
||||
@@ -563,6 +563,7 @@ 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()
|
||||
|
||||
@@ -618,6 +619,16 @@ class Stream(WebRTCConnectionMixin):
|
||||
)
|
||||
+ " 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:
|
||||
while True:
|
||||
time.sleep(0.1)
|
||||
@@ -626,11 +637,7 @@ class Stream(WebRTCConnectionMixin):
|
||||
click.style("INFO", fg="green")
|
||||
+ ":\t Keyboard interruption in main thread... closing server."
|
||||
)
|
||||
r = httpx.post(
|
||||
URL + "/unregister",
|
||||
json={"url": host, "code": code},
|
||||
headers={"Authorization": token or get_token() or ""},
|
||||
)
|
||||
unregister()
|
||||
t.join(timeout=5)
|
||||
for tunnel in CURRENT_TUNNELS:
|
||||
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.
|
||||
|
||||
<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
|
||||
|
||||
@@ -25,10 +25,10 @@ Turn any python function into a real-time audio and video stream over WebRTC or
|
||||
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
|
||||
pip install fastrtc[vad, tts]
|
||||
pip install fastrtc[vad, stt, tts]
|
||||
```
|
||||
|
||||
## Quickstart
|
||||
|
||||
@@ -304,7 +304,11 @@
|
||||
</div>
|
||||
{:else if stream_state === "open"}
|
||||
<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
|
||||
audio_source_callback={() => stream}
|
||||
stream_state={"open"}
|
||||
|
||||
Reference in New Issue
Block a user