Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
63 |
-
|
64 |
-
if
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
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
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
|
97 |
-
|
98 |
-
|
99 |
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
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!")
|