fix: lazy-load trafilatura+edge_tts, unbuffered stdout, disable gradio analytics
Browse files12 unmodified lines1314151617188 unmodified lines27282930313233343536157 unmodified lines19419519619719819932 unmodified lines232233234235236237668 unmodified lines90690790890912 unmodified linesadd news lower-third, ticker, channel logo β instant news-style reel"""# ββ stdlib ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββimport asyncioimport os8 unmodified linesimport numpy as npimport requestsimport soundfile as sfimport trafilaturaimport edge_ttsfrom groq import Groqfrom PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageEnhance# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# CONSTANTS157 unmodified lines# URL SCRAPING# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββdef scrape_url(url: str) -> str:try:dl = trafilatura.fetch_url(url)text = trafilatura.extract(dl, include_tables=False, include_comments=False, favor_recall=True)32 unmodified lines# AUDIO β Edge TTS# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββasync def _edge_save(text: str, voice: str, path: str) -> None:await edge_tts.Communicate(text, voice).save(path)def generate_audio_edge(text: str, voice_display: str) -> str:668 unmodified lines| **Pexels** *(optional)* | Free HD stock video backgrounds | [pexels.com/api](https://www.pexels.com/api/) |""")demo.launch(server_name="0.0.0.0", server_port=7860)12 unmodified lines131415161718192021228 unmodified lines313233343536373839157 unmodified lines19719819920020120220332 unmodified lines236237238239240241242668 unmodified lines91191291391491591612 unmodified linesadd news lower-third, ticker, channel logo β instant news-style reel"""# ββ unbuffered stdout so container logs appear in real-time ββββββββββββββββββimport syssys.stdout.reconfigure(line_buffering=True)# ββ stdlib ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββimport asyncioimport os8 unmodified linesimport numpy as npimport requestsimport soundfile as sffrom groq import Groqfrom PIL import Image, ImageDraw, ImageFont, ImageFilter, ImageEnhanceprint("β all top-level imports done", flush=True)# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ# CONSTANTS157 unmodified lines# URL SCRAPING# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββdef scrape_url(url: str) -> str:import trafilatura # lazy β avoid slow startuptry:dl = trafilatura.fetch_url(url)text = trafilatura.extract(dl, include_tables=False, include_comments=False, favor_recall=True)32 unmodified lines# AUDIO β Edge TTS# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββasync def _edge_save(text: str, voice: str, path: str) -> None:import edge_tts # lazy β avoid slow startupawait edge_tts.Communicate(text, voice).save(path)def generate_audio_edge(text: str, voice_display: str) -> str:668 unmodified lines| **Pexels** *(optional)* | Free HD stock video backgrounds | [pexels.com/api](https://www.pexels.com/api/) |""")os.environ.setdefault("GRADIO_ANALYTICS_ENABLED", "False") # prevent analytics hangprint("β UI built, launching Gradio serverβ¦", flush=True)demo.launch(server_name="0.0.0.0", server_port=7860)
app.py+9-2