in experiments/babel/app/pages/welcome.py [0:0]
def welcome_page(app_state: me.state):
"""Welcome Voices page"""
state = me.state(PageState)
state.voices = get_chosen_voices()
if not state.loaded:
print("There're no voices to display")
state.audio_output_metadata = filter_babel_metadata("pages/welcome_event.json")
state.loaded = True
print(f"loaded {len(state.audio_output_metadata)} voices")
with me.box(style=CONTENT_STYLE):
with me.box(
on_click=regenerate_welcome,
):
me.text(
state.welcome_statement,
type="headline-4",
style=FANCY_2,
)
# me.text("Enter text to voice", type="headline-6")
# me.text(
# f"Using {len(state.voices)} Chirp 3: HD voices",
# style=me.Style(font_style="italic"),
# )
# subtle_chat_input_journey()
if state.is_loading:
with me.box(
style=me.Style(
text_align="center"
)
):
me.progress_spinner()
elif state.audio_output_metadata:
with me.box(
style=me.Style(
display="grid", grid_template_columns="1fr 1fr", text_align="center"
)
):
# for uri in state.audio_output_infos:
# me.audio(src=uri)
sorted_metadata = sorted(
state.audio_output_metadata,
key=lambda voice: voice["language_code"],
)
for item in sorted_metadata:
# print(item)
audio_url = f"{BUCKET_PATH}/{item['audio_path']}"
# print(audio_url)
with me.box(
style=me.Style(
display="flex",
flex_direction="column",
gap=5,
padding=me.Padding(top=10, left=10, right=10, bottom=12),
)
):
me.text(
f"{item["language_code"]} ({item["gender"].lower()}, {item["voice_name"]})",
style=me.Style(font_weight="bold"),
)
me.audio(src=audio_url)
me.text(item["text"])