Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| def process_keywords_and_video(url, excel_file): | |
| metadata, error = fetch_video_metadata(url) | |
| if error: | |
| return error, None | |
| transcript, error = fetch_transcript(url) | |
| if error: | |
| return error, None | |
| sentences = split_long_sentences(transcript) | |
| keywords, attributes = read_keywords(excel_file) | |
| matched_keywords = match_keywords_in_sentences(sentences, keywords) | |
| sentiment_results = analyze_sentiment_for_keywords(matched_keywords, sentences) | |
| wordclouds = generate_word_clouds(matched_keywords) | |
| pdf_file = generate_pdf_with_sections(metadata, sentiment_results, wordclouds) | |
| return "Processing completed successfully!", pdf_file | |
| # Gradio App | |
| with gr.Blocks() as iface: | |
| gr.Markdown("<h1>Auto-Insight: YouTube Video Analyzer for Automobiles</h1>") | |
| video_url = gr.Textbox(label="YouTube Video URL", placeholder="Enter the YouTube video URL") | |
| excel_file = gr.File(label="Upload Excel File with Keywords") | |
| process_button = gr.Button("Analyze Video") | |
| processing_status = gr.Textbox(label="Processing Status", interactive=False) | |
| pdf_output = gr.File(label="Download Sentiment Report (PDF)") | |
| process_button.click( | |
| process_keywords_and_video, | |
| inputs=[video_url, excel_file], | |
| outputs=[processing_status, pdf_output] | |
| ) | |
| iface.launch(share=True) | |