temo12 commited on
Commit
fcecf5e
·
verified ·
1 Parent(s): eed98a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -7
app.py CHANGED
@@ -1,10 +1,36 @@
1
-
2
  import gradio as gr
3
 
4
- # Example Gradio function for sentiment analysis (adjust with your model/logic)
5
- def sentiment_analyze(input_text):
6
- return f"Sentiment analyzed for: {input_text}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
- # Create Gradio interface
9
- app = gr.Interface(fn=sentiment_analyze, inputs="text", outputs="text")
10
- app.launch()
 
 
1
  import gradio as gr
2
 
3
+ def process_keywords_and_video(url, excel_file):
4
+ metadata, error = fetch_video_metadata(url)
5
+ if error:
6
+ return error, None
7
+
8
+ transcript, error = fetch_transcript(url)
9
+ if error:
10
+ return error, None
11
+
12
+ sentences = split_long_sentences(transcript)
13
+ keywords, attributes = read_keywords(excel_file)
14
+ matched_keywords = match_keywords_in_sentences(sentences, keywords)
15
+ sentiment_results = analyze_sentiment_for_keywords(matched_keywords, sentences)
16
+ wordclouds = generate_word_clouds(matched_keywords)
17
+ pdf_file = generate_pdf_with_sections(metadata, sentiment_results, wordclouds)
18
+
19
+ return "Processing completed successfully!", pdf_file
20
+
21
+ # Gradio App
22
+ with gr.Blocks() as iface:
23
+ gr.Markdown("<h1>Auto-Insight: YouTube Video Analyzer for Automobiles</h1>")
24
+ video_url = gr.Textbox(label="YouTube Video URL", placeholder="Enter the YouTube video URL")
25
+ excel_file = gr.File(label="Upload Excel File with Keywords")
26
+ process_button = gr.Button("Analyze Video")
27
+ processing_status = gr.Textbox(label="Processing Status", interactive=False)
28
+ pdf_output = gr.File(label="Download Sentiment Report (PDF)")
29
+
30
+ process_button.click(
31
+ process_keywords_and_video,
32
+ inputs=[video_url, excel_file],
33
+ outputs=[processing_status, pdf_output]
34
+ )
35
 
36
+ iface.launch(share=True)