Skip to content

Commit

Permalink
add code (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
freddyaboulton authored Mar 7, 2025
1 parent 7dfee78 commit 11dae29
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backend/fastrtc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .reply_on_pause import AlgoOptions, ReplyOnPause, SileroVadOptions
from .reply_on_stopwords import ReplyOnStopWords
from .speech_to_text import MoonshineSTT, get_stt_model
from .stream import Stream
from .stream import Stream, UIArgs
from .text_to_speech import KokoroTTSOptions, get_tts_model
from .tracks import (
AsyncAudioVideoStreamHandler,
Expand Down Expand Up @@ -62,4 +62,5 @@
"get_tts_model",
"KokoroTTSOptions",
"wait_for_item",
"UIArgs",
]
58 changes: 58 additions & 0 deletions backend/fastrtc/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class Body(BaseModel):
class UIArgs(TypedDict):
title: NotRequired[str]
"""Title of the demo"""
subtitle: NotRequired[str]
"""Subtitle of the demo. Text will be centered and displayed below the title."""
icon: NotRequired[str]
"""Icon to display on the button instead of the wave animation. The icon should be a path/url to a .svg/.png/.jpeg file."""
icon_button_color: NotRequired[str]
Expand Down Expand Up @@ -192,6 +194,14 @@ def _generate_default_ui(
</h1>
"""
)
if ui_args.get("subtitle"):
gr.Markdown(
f"""
<div style='text-align: center'>
{ui_args.get("subtitle")}
</div>
"""
)
with gr.Row():
with gr.Column():
if additional_input_components:
Expand Down Expand Up @@ -231,6 +241,14 @@ def _generate_default_ui(
</h1>
"""
)
if ui_args.get("subtitle"):
gr.Markdown(
f"""
<div style='text-align: center'>
{ui_args.get("subtitle")}
</div>
"""
)
with gr.Row():
if additional_input_components:
with gr.Column():
Expand Down Expand Up @@ -271,6 +289,14 @@ def _generate_default_ui(
</h1>
"""
)
if ui_args.get("subtitle"):
gr.Markdown(
f"""
<div style='text-align: center'>
{ui_args.get("subtitle")}
</div>
"""
)
with gr.Column(elem_classes=["my-column"]):
with gr.Group(elem_classes=["my-group"]):
image = WebRTC(
Expand Down Expand Up @@ -310,6 +336,14 @@ def _generate_default_ui(
</h1>
"""
)
if ui_args.get("subtitle"):
gr.Markdown(
f"""
<div style='text-align: center'>
{ui_args.get("subtitle")}
</div>
"""
)
with gr.Row():
with gr.Column():
for component in additional_input_components:
Expand Down Expand Up @@ -354,6 +388,14 @@ def _generate_default_ui(
</h1>
"""
)
if ui_args.get("subtitle"):
gr.Markdown(
f"""
<div style='text-align: center'>
{ui_args.get("subtitle")}
</div>
"""
)
with gr.Row():
with gr.Column():
with gr.Group():
Expand Down Expand Up @@ -397,6 +439,14 @@ def _generate_default_ui(
</h1>
"""
)
if ui_args.get("subtitle"):
gr.Markdown(
f"""
<div style='text-align: center'>
{ui_args.get("subtitle")}
</div>
"""
)
with gr.Row():
with gr.Column():
with gr.Group():
Expand Down Expand Up @@ -441,6 +491,14 @@ def _generate_default_ui(
</h1>
"""
)
if ui_args.get("subtitle"):
gr.Markdown(
f"""
<div style='text-align: center'>
{ui_args.get("subtitle")}
</div>
"""
)
with gr.Row():
with gr.Column():
with gr.Group():
Expand Down

0 comments on commit 11dae29

Please sign in to comment.