Update app.py
Browse files290 unmodified lines291292293294295296672 unmodified lines96997097197297397497597697797897998098198298398498598698798898955 unmodified lines1045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204290 unmodified linesNone,None,None,)672 unmodified linesdesc="FinTok audio ready!")yield ("""### ✅ FinTok audio ready!The financial story, script and **all four voice tracks** have been generated.You can listen to every scene below.**Next step: avatar generation.**""",output,audio_hook,audio_intro,audio_explanation,audio_outro,)return55 unmodified lines# UI# ============================================================with gr.Blocks(title="FinTok") as demo:gr.Markdown("""# FinTok### Financial intelligence, made for social.Choose a company, fiscal year and 10-K section.FinTok randomly discovers an interesting financial storyinside the filing and transforms it into short-form content.""")# ========================================================# SELECTORS# ========================================================with gr.Row():company = gr.Dropdown(choices=companies,value=default_company,label="Company",interactive=True)year = gr.Dropdown(choices=years,value=default_year,label="Fiscal year",interactive=True)item = gr.Dropdown(choices=items,value=default_item,label="10-K Section",interactive=True)# ========================================================# GENERATE BUTTON# ========================================================generate_button = gr.Button("Generate FinTok",variant="primary",size="lg")# ========================================================# LIVE STATUS# ========================================================status = gr.Markdown("")# ========================================================# FINAL SCRIPT# ========================================================result = gr.Markdown("")# ========================================================# AUDIO OUTPUTS# ========================================================gr.Markdown("""## 🔊 Generated voicesThe four scene tracks will appear here when generation is complete.""")with gr.Row():audio_hook = gr.Audio(label="🎯 Hook — Andrea",type="filepath")audio_intro = gr.Audio(label="🎙️ Intro — Miriam",type="filepath")with gr.Row():audio_explanation = gr.Audio(label="📊 Explanation — Miriam",type="filepath")audio_outro = gr.Audio(label="👋 Outro — Andrea",type="filepath")# ========================================================# DROPDOWN EVENTS# ========================================================company.change(fn=update_years,inputs=company,outputs=year)company.change(fn=update_items,inputs=[company,year],outputs=item)year.change(fn=update_items,inputs=[company,year],outputs=item)# ========================================================# GENERATION# ========================================================generate_button.click(fn=generate_fintok,inputs=[company,year,item],outputs=[status,result,audio_hook,audio_intro,audio_explanation,audio_outro,])# ============================================================290 unmodified lines291292293294295296297298672 unmodified lines9719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103455 unmodified lines1090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540290 unmodified linesNone,None,None,None,None,)672 unmodified linesdesc="FinTok audio ready!")# =================================================# DOWNLOADABLE OUTPUTS# =================================================downloadable_json = audio_work_dir / "fintok.json"with downloadable_json.open("w",encoding="utf-8") as f:json.dump(audio_payload,f,ensure_ascii=False,indent=2)audio_zip = audio_work_dir / "fintok_audio.zip"with zipfile.ZipFile(audio_zip,"w",compression=zipfile.ZIP_DEFLATED) as z:archive_names = ["01_hook_andrea.wav","02_intro_miriam.wav","03_explanation_miriam.wav","04_outro_andrea.wav",]for audio_path, archive_name in zip(audio_paths,archive_names):z.write(audio_path,arcname=archive_name)yield ("""### ✨ Your FinTok is readyThe financial story has been researched, written and voiced.Listen to each scene below or download the complete **JSON** and **audio pack**.""",output,audio_hook,audio_intro,audio_explanation,audio_outro,str(downloadable_json),str(audio_zip),)return55 unmodified lines# UI# ============================================================FINTOK_CSS = """:root {--fintok-pink: #c85d91;--fintok-pink-dark: #a94e7d;--fintok-blush: #fff4f8;--fintok-lilac: #f5f0ff;--fintok-ink: #302735;--fintok-muted: #756b78;--fintok-border: #eadde6;}.gradio-container {background:radial-gradient(circle at 8% 2%, rgba(240, 189, 214, .30), transparent 26rem),radial-gradient(circle at 94% 8%, rgba(210, 197, 246, .30), transparent 25rem),#fffafb !important;}#fintok-shell {max-width: 1120px;margin: 0 auto;}#hero {border: 1px solid var(--fintok-border);border-radius: 28px;padding: 38px 42px 34px;margin: 14px 0 22px;background: linear-gradient(135deg,rgba(255,255,255,.97),rgba(255,244,248,.96) 55%,rgba(246,241,255,.96));box-shadow: 0 16px 45px rgba(86, 55, 75, .08);}#hero h1 {margin: 0 0 6px;font-size: clamp(2.6rem, 7vw, 4.7rem);line-height: .98;letter-spacing: -0.055em;color: var(--fintok-ink);}#hero .accent {color: var(--fintok-pink-dark);}#hero .tagline {margin-top: 13px;font-size: 1.22rem;font-weight: 600;color: #584c5c;}#hero .description {max-width: 850px;margin-top: 18px;color: var(--fintok-muted);line-height: 1.65;font-size: 1rem;}#hero .chips {display: flex;flex-wrap: wrap;gap: 9px;margin-top: 22px;}#hero .chip {padding: 8px 13px;border-radius: 999px;background: rgba(255,255,255,.82);border: 1px solid #eadbe4;color: #665866;font-size: .88rem;font-weight: 600;}#poc-note {margin-top: 22px;padding: 16px 18px;border-radius: 16px;background: rgba(255,255,255,.66);border: 1px solid #eadde6;color: #746774;line-height: 1.55;font-size: .9rem;}#poc-note strong {color: #5b4b58;}.section-card {border: 1px solid var(--fintok-border) !important;border-radius: 22px !important;background: rgba(255,255,255,.88) !important;box-shadow: 0 8px 26px rgba(78, 54, 71, .055) !important;padding: 12px !important;}.section-heading {margin: 12px 3px 14px !important;}.section-heading h2 {color: var(--fintok-ink);letter-spacing: -.025em;margin-bottom: 3px;}.section-heading p {color: var(--fintok-muted);}#generate-btn {min-height: 52px;border-radius: 15px !important;border: 0 !important;font-weight: 700 !important;font-size: 1rem !important;background: linear-gradient(135deg, #c85d91, #a95b9c) !important;box-shadow: 0 8px 20px rgba(184, 79, 130, .22) !important;}#generate-btn:hover {transform: translateY(-1px);box-shadow: 0 10px 24px rgba(184, 79, 130, .28) !important;}#status-box {border-radius: 18px;overflow: hidden;}#story-output {border: 1px solid var(--fintok-border);border-radius: 22px;padding: 18px 22px;background: rgba(255,255,255,.90);}.audio-card {border-radius: 18px !important;overflow: hidden;}.download-card {border: 1px solid var(--fintok-border) !important;border-radius: 18px !important;background: linear-gradient(145deg, #ffffff, #fff8fb) !important;}.footer-note {text-align: center;color: #918590;font-size: .84rem;margin: 26px 0 8px;}@media (max-width: 700px) {#hero {padding: 28px 24px;border-radius: 22px;}}"""with gr.Blocks(title="FinTok",theme=gr.themes.Soft(),css=FINTOK_CSS,) as demo:with gr.Column(elem_id="fintok-shell"):# ========================================================# HERO# ========================================================gr.HTML("""<section id="hero"><div style="font-size:.82rem;font-weight:700;letter-spacing:.14em;text-transform:uppercase;color:#b84f82;margin-bottom:14px;">AI · Financial storytelling · Voice</div><h1>Finance, but make it<span class="accent">FinTok.</span></h1><div class="tagline">Turning dense financial filings into short storiespeople actually want to hear.</div><div class="description">FinTok explores public 10-K filings, discovers a relevantfinancial story, checks that it is grounded in the source,turns it into a four-scene short-form script and generatesthe voices of Andrea and Miriam with AI.<br><br>The goal is to bridge the gap between<b>financial intelligence</b> and<b>accessible social content</b> while preservingtraceability to the original filing.</div><div class="chips"><span class="chip">① Discover</span><span class="chip">② Extract facts</span><span class="chip">③ Editorial check</span><span class="chip">④ Write the story</span><span class="chip">⑤ Generate voices</span></div><div id="poc-note"><strong>About this PoC.</strong>This proof of concept focuses on the core FinTok pipeline:financial story discovery, fact-grounded script generationand AI voice synthesis. Video generation is intentionallyleft outside the current PoC because open-sourcetalking-avatar pipelines introduce substantial inferencetime and computational requirements, while the larger,higher-quality open-source alternatives rely on dependencystacks that are not fully compatible with this repository'scurrent runtime. Keeping video out of scope makes the PoClighter, reproducible and focused on validating the coreidea.</div></section>""")# ========================================================# CREATE# ========================================================gr.Markdown("""## Create your FinTok ✨Choose where FinTok should look. Each run explores a random part of the selected section, so the same selection can uncover a different story.""",elem_classes="section-heading")with gr.Column(elem_classes="section-card"):with gr.Row():company = gr.Dropdown(choices=companies,value=default_company,label="Company",info="Select a company from the 10-K corpus.",interactive=True,scale=1,)year = gr.Dropdown(choices=years,value=default_year,label="Fiscal year",info="Choose the filing year.",interactive=True,scale=1,)item = gr.Dropdown(choices=items,value=default_item,label="10-K section",info="Choose where FinTok should search for a story.",interactive=True,)generate_button = gr.Button("✨ Generate my FinTok",variant="primary",size="lg",elem_id="generate-btn",)# ========================================================# LIVE STATUS# ========================================================status = gr.Markdown("",elem_id="status-box",)# ========================================================# STORY# ========================================================gr.Markdown("""## Your storyOnce FinTok finds a story that passes the editorial check, the four-scene script will appear here.""",elem_classes="section-heading")result = gr.Markdown("",elem_id="story-output",)# ========================================================# AUDIO# ========================================================gr.Markdown("""## Meet the voices 🎧The story is split between **Andrea** and **Miriam** and voiced scene by scene with F5-TTS.""",elem_classes="section-heading")with gr.Row():audio_hook = gr.Audio(label="🎯 Hook · Andrea",type="filepath",elem_classes="audio-card",)audio_intro = gr.Audio(label="🎙️ Intro · Miriam",type="filepath",elem_classes="audio-card",)with gr.Row():audio_explanation = gr.Audio(label="📈 Explanation · Miriam",type="filepath",elem_classes="audio-card",)audio_outro = gr.Audio(label="✨ Outro · Andrea",type="filepath",elem_classes="audio-card",)# ========================================================# DOWNLOADS# ========================================================gr.Markdown("""## Take it with you ↓Download the structured FinTok output for reproducibility or grab all four generated voice tracks in one pack.""",elem_classes="section-heading")with gr.Row():json_download = gr.File(label="FinTok JSON",interactive=False,elem_classes="download-card",)audio_download = gr.File(label="Audio pack · ZIP",interactive=False,elem_classes="download-card",)gr.HTML("""<div class="footer-note">FinTok · AI-powered financial storytelling from public 10-K filings</div>""")# ========================================================# DROPDOWN EVENTS# ========================================================company.change(fn=update_years,inputs=company,outputs=year)company.change(fn=update_items,inputs=[company,year],outputs=item)year.change(fn=update_items,inputs=[company,year],outputs=item)# ========================================================# GENERATION# ========================================================generate_button.click(fn=generate_fintok,inputs=[company,year,item],outputs=[status,result,audio_hook,audio_intro,audio_explanation,audio_outro,json_download,audio_download,])# ============================================================
app.py+460-124