import gradio as gr from tok2text import extract_recipe def process_tiktok_url(tiktok_url): try: formatted_recipe, formatted_recipe_path, transcript_path = extract_recipe(tiktok_url) return formatted_recipe, str(formatted_recipe_path), str(transcript_path) except Exception as e: return f"Error: {str(e)}", None demo = gr.Interface( fn=process_tiktok_url, inputs=gr.Textbox(label="TikTok URL"), outputs=[ gr.Textbox(label="Formatted Recipe"), gr.File(label="Download Formatted Recipe"), gr.File(label="Download Raw Transcript"), ], title="TikTok Recipe Extractor", description="Extract and format recipes from TikTok videos.", examples=[ ["https://www.tiktok.com/@emmaaaaaaam_/video/7348493781961886981"], ["https://www.tiktok.com/@vanessacooks_/video/7280652972567170346"], ["https://www.tiktok.com/@freddsters/video/7027220930124451078?lang=en"] ], allow_flagging="never" ) if __name__ == "__main__": demo.launch()