yiqing111 commited on
Commit
3b9273c
Β·
verified Β·
1 Parent(s): e239222

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -53
app.py CHANGED
@@ -2,24 +2,10 @@ import streamlit as st
2
  import torch
3
  from transformers import AutoTokenizer
4
  import whisper
5
- import subprocess
6
  import os
7
  import pandas as pd
8
  from dl import PitchEvaluationModel # Import model
9
 
10
- def download_youtube_video(url, output_file="pitch_video.mp4"):
11
- """Download YouTube video using yt-dlp."""
12
- if "youtube.com" not in url and "youtu.be" not in url:
13
- st.error("❌ Invalid URL! Please enter a valid YouTube link.")
14
- return None
15
- try:
16
- command = ["yt-dlp", "-f", "mp4", "-o", output_file, url]
17
- subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
18
- return output_file
19
- except subprocess.CalledProcessError:
20
- st.error("❌ Failed to download the video. Please check the URL and try again.")
21
- return None
22
-
23
  def transcribe_video(video_file):
24
  """Transcribe video using Whisper."""
25
  try:
@@ -59,45 +45,35 @@ def evaluate_pitch(transcript, model, tokenizer, device):
59
  st.set_page_config(page_title="Pitch Evaluation App", layout="wide")
60
  st.title("πŸš€ Pitch Evaluation")
61
 
62
- option = st.radio("Choose Input Method", ("YouTube URL", "Upload File"), horizontal=True)
63
-
64
- if option == "YouTube URL":
65
- url = st.text_input("πŸŽ₯ Enter YouTube URL")
66
- if st.button("Download and Transcribe", use_container_width=True):
67
- video_file = download_youtube_video(url)
68
- if video_file:
69
- transcript = transcribe_video(video_file)
70
- st.text_area("πŸ“œ Transcript", transcript, height=200)
71
- elif option == "Upload File":
72
- uploaded_file = st.file_uploader("πŸ“‚ Upload Video", type=["mp4"], help="Upload a video file for transcription and evaluation.")
73
- if uploaded_file is not None:
74
- if uploaded_file.type != "video/mp4":
75
- st.error("❌ Invalid file format! Please upload an MP4 file.")
76
- else:
77
- with open("uploaded_video.mp4", "wb") as f:
78
- f.write(uploaded_file.getbuffer())
79
- transcript = transcribe_video("uploaded_video.mp4")
80
- st.text_area("πŸ“œ Transcript", transcript, height=200)
81
 
82
- if 'transcript' in locals() and transcript:
83
- model, tokenizer, device = load_model()
84
- if model is not None:
85
- clarity, team, traction = evaluate_pitch(transcript, model, tokenizer, device)
86
- if None not in (clarity, team, traction):
87
- # Create a DataFrame for the scoring table
88
- categories = ["Clarity & Conciseness", "Team-Market Fit", "Traction / Validation"]
89
- scores = [clarity, team, traction]
90
- descriptions = [
91
- "Extremely clear, direct, and easy to follow;no fluff, just essential details." if clarity == 5 else "Mostly clear, with only minor unnecessary details." if clarity == 4 else "Somewhat clear but includes extra details or minor distractions." if clarity == 3 else "Lacks clarity; hard to follow; too much fluff or filler." if clarity == 2 else "Unclear, rambling, and difficult to understand.",
92
- "Founders have highly relevant skills & experience to execute this successfully." if team == 5 else "Founders have good experience but may lack some key skills." if team == 4 else "Some relevant experience but gaps in expertise." if team == 3 else "Limited relevant experience; execution ability is questionable." if team == 2 else "No clear expertise in this space; team seems unqualified.",
93
- "Strong proof of demand (users, revenue, engagement, partnerships, etc.)." if traction == 5 else "Good early validation with promising signs of demand." if traction == 4 else "Some traction but not yet convincing." if traction == 3 else "Weak or vague traction, with little evidence of demand." if traction == 2 else "No validation or proof that people want this."
94
- ]
95
- df = pd.DataFrame({"Category": categories, "Score (1-5)": scores, "Evaluation": descriptions})
96
 
97
- st.write("## πŸ“Š Evaluation Results")
98
- st.table(df)
99
 
100
- if ((clarity + team + traction)/3) >=3.5:
101
- st.write("## πŸŽ‰ Congrats! You have a high possibility to be accepted")
102
- else:
103
- st.write("## πŸ™Œ Need More Practice, but don't give up!")
 
2
  import torch
3
  from transformers import AutoTokenizer
4
  import whisper
 
5
  import os
6
  import pandas as pd
7
  from dl import PitchEvaluationModel # Import model
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  def transcribe_video(video_file):
10
  """Transcribe video using Whisper."""
11
  try:
 
45
  st.set_page_config(page_title="Pitch Evaluation App", layout="wide")
46
  st.title("πŸš€ Pitch Evaluation")
47
 
48
+ uploaded_file = st.file_uploader("πŸ“‚ Upload Video", type=["mp4"], help="Upload a video file for transcription and evaluation.")
49
+ if uploaded_file is not None:
50
+ if uploaded_file.type != "video/mp4":
51
+ st.error("❌ Invalid file format! Please upload an MP4 file.")
52
+ else:
53
+ with open("uploaded_video.mp4", "wb") as f:
54
+ f.write(uploaded_file.getbuffer())
55
+ transcript = transcribe_video("uploaded_video.mp4")
56
+ st.text_area("πŸ“œ Transcript", transcript, height=200)
 
 
 
 
 
 
 
 
 
 
57
 
58
+ if transcript:
59
+ model, tokenizer, device = load_model()
60
+ if model is not None:
61
+ clarity, team, traction = evaluate_pitch(transcript, model, tokenizer, device)
62
+ if None not in (clarity, team, traction):
63
+ # Create a DataFrame for the scoring table
64
+ categories = ["Clarity & Conciseness", "Team-Market Fit", "Traction / Validation"]
65
+ scores = [clarity, team, traction]
66
+ descriptions = [
67
+ "Extremely clear, direct, and easy to follow; no fluff, just essential details." if clarity == 5 else "Mostly clear, with only minor unnecessary details." if clarity == 4 else "Somewhat clear but includes extra details or minor distractions." if clarity == 3 else "Lacks clarity; hard to follow; too much fluff or filler." if clarity == 2 else "Unclear, rambling, and difficult to understand.",
68
+ "Founders have highly relevant skills & experience to execute this successfully." if team == 5 else "Founders have good experience but may lack some key skills." if team == 4 else "Some relevant experience but gaps in expertise." if team == 3 else "Limited relevant experience; execution ability is questionable." if team == 2 else "No clear expertise in this space; team seems unqualified.",
69
+ "Strong proof of demand (users, revenue, engagement, partnerships, etc.)." if traction == 5 else "Good early validation with promising signs of demand." if traction == 4 else "Some traction but not yet convincing." if traction == 3 else "Weak or vague traction, with little evidence of demand." if traction == 2 else "No validation or proof that people want this."
70
+ ]
71
+ df = pd.DataFrame({"Category": categories, "Score (1-5)": scores, "Evaluation": descriptions})
72
 
73
+ st.write("## πŸ“Š Evaluation Results")
74
+ st.table(df)
75
 
76
+ if ((clarity + team + traction)/3) >= 3.5:
77
+ st.write("## πŸŽ‰ Congrats! You have a high possibility to be accepted")
78
+ else:
79
+ st.write("## πŸ™Œ Need More Practice, but don't give up!")