Blake commited on
Commit
ab41f96
1 Parent(s): 46c4d53

First commit

Browse files
Files changed (5) hide show
  1. .DS_Store +0 -0
  2. README.md +12 -3
  3. app.py +110 -0
  4. prompt.txt +81 -0
  5. requirements.txt +3 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
  title: VideoInterviewAutomation
3
  emoji: 🚀
4
- colorFrom: purple
5
- colorTo: purple
6
  sdk: gradio
7
  sdk_version: 4.16.0
8
  app_file: app.py
@@ -10,4 +10,13 @@ pinned: false
10
  license: mit
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  title: VideoInterviewAutomation
3
  emoji: 🚀
4
+ colorFrom: yellow
5
+ colorTo: red
6
  sdk: gradio
7
  sdk_version: 4.16.0
8
  app_file: app.py
 
10
  license: mit
11
  ---
12
 
13
+ # YouTube Interview Analysis Tool
14
+
15
+ This application evaluates YouTube video interviews to recommend whether the interviewee should be considered for a further interview based on a specific rubric. It leverages the YouTube Transcript API to fetch transcripts, analyzes the content with OpenAI's GPT-4, and provides recommendations through a simple web interface powered by Gradio.
16
+
17
+ ## Features
18
+
19
+ - **Video ID Extraction**: Extracts the video ID from a YouTube URL.
20
+ - **Transcript Retrieval**: Retrieves the video's transcript along with its total duration and an estimated number of pauses.
21
+ - **GPT-4 Analysis**: Analyzes the transcript data against a predefined rubric to assess the interviewee's performance.
22
+ - **Gradio Interface**: Offers a user-friendly web interface for inputting YouTube URLs and receiving recommendations.
app.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from youtube_transcript_api import YouTubeTranscriptApi
3
+ import openai
4
+ from urllib.parse import urlparse, parse_qs
5
+ import re
6
+ import os
7
+ import logging
8
+
9
+ logging.basicConfig(filename='app.log', filemode='a',
10
+ format='%(name)s - %(levelname)s - %(message)s', level=logging.DEBUG)
11
+
12
+
13
+ def get_video_id_from_url(url):
14
+ """
15
+ Extracts the video ID from the YouTube URL.
16
+ """
17
+ try:
18
+ url_data = urlparse(url)
19
+ query = parse_qs(url_data.query)
20
+ video_id = query.get("v")
21
+ if video_id:
22
+ logging.info(f"Video ID {video_id[0]} extracted from URL.")
23
+ return video_id[0]
24
+ else:
25
+ logging.warning(f"No video ID found in URL: {url}")
26
+ return None
27
+ except Exception as e:
28
+ logging.error(f"Error extracting video ID from URL {url}: {e}")
29
+ return None
30
+
31
+
32
+ def get_transcript_data_and_pause_count(video_id):
33
+ """
34
+ Retrieves the transcript for the given video ID, calculates the total duration, and estimates the number of pauses.
35
+ """
36
+ try:
37
+ transcript = YouTubeTranscriptApi.get_transcript(video_id, languages=['en'])
38
+ if transcript:
39
+ last_segment = transcript[-1]
40
+ total_duration = last_segment['start'] + last_segment['duration']
41
+
42
+ # Estimate the number of pauses
43
+ pauses = 0
44
+ for i in range(1, len(transcript)):
45
+ current_start = transcript[i]['start']
46
+ previous_end = transcript[i-1]['start'] + transcript[i-1]['duration']
47
+ if current_start > previous_end:
48
+ pauses += 1
49
+
50
+ full_transcript = " ".join(segment['text'] for segment in transcript)
51
+ logging.info(f"Transcript retrieved successfully for video ID {video_id}.")
52
+ return full_transcript, total_duration // 60, pauses
53
+ except Exception as e:
54
+ logging.error(f"Failed to retrieve transcript for video ID {video_id}. Error: {e}")
55
+ return None, None, None
56
+
57
+ def analyze_transcript(url):
58
+ """
59
+ Analyzes the YouTube video transcript for total length and estimates the number of pauses.
60
+ """
61
+ try:
62
+ with open('prompt.txt', 'r') as file:
63
+ prompt = file.read()
64
+ except Exception as e:
65
+ logging.error(f"Error opening or reading from 'prompt.txt': {e}")
66
+ return "Error processing the prompt file."
67
+
68
+ try:
69
+ video_id = get_video_id_from_url(url)
70
+ if not video_id:
71
+ logging.error("Invalid URL provided.")
72
+ return "Invalid URL. Please enter a valid YouTube video URL."
73
+
74
+ full_transcript, total_duration, pauses = get_transcript_data_and_pause_count(
75
+ video_id)
76
+
77
+ if full_transcript is None: # If there was an error retrieving the transcript
78
+ logging.error("Error retrieving the transcript.")
79
+ return pauses
80
+
81
+ # Define the prompt for GPT evaluation based on the rubric
82
+ prompt = prompt.format(full_transcript, pauses, total_duration)
83
+
84
+ # Using the new OpenAI client structure
85
+ client = openai.OpenAI(api_key=os.getenv('OpenAIKey'))
86
+ response = client.chat.completions.create(
87
+ model="gpt-4",
88
+ messages=[
89
+ {"role": "system", "content": "You are a helpful assistant."},
90
+ {"role": "user", "content": prompt}
91
+ ],
92
+ )
93
+
94
+ decision = response.choices[0].message.content.strip()
95
+ return decision
96
+ except Exception as e:
97
+ logging.error(f"An error occurred during the analysis: {e}")
98
+ return f"An error occurred during the processing. {e}"
99
+
100
+
101
+ # Gradio interface
102
+ iface = gr.Interface(
103
+ fn=analyze_transcript,
104
+ inputs=gr.Textbox(label="Enter YouTube Video URL"), # Updated
105
+ outputs=gr.Textbox(label="Interview Recommendation"), # Updated
106
+ description="This app evaluates a YouTube video interview transcript against a specific rubric to recommend if the person should receive an interview."
107
+ )
108
+
109
+ # Launch the app
110
+ iface.launch()
prompt.txt ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Candidate's Transcript:
2
+ {}
3
+
4
+ Candidate's Number of Pauses:
5
+ {}
6
+
7
+ Candidate's Length of Video:
8
+ {} minutes
9
+
10
+ Introduction:
11
+ You are tasked with evaluating a candidate's interview transcript for a highly competitive position that demands not only technical expertise but also a strong alignment with our educational mission, leadership qualities, and a collaborative spirit. This evaluation requires a rigorous, critical analysis. Additionally, assess the presentation’s duration and pacing, as the ability to convey information effectively within a constrained timeframe and with minimal unnecessary pauses is crucial. We expect assessors to employ a stringent standard, focusing on identifying any shortcomings, gaps in knowledge, or areas for improvement. Our aim is to ensure only the highest caliber candidates progress, reflecting our no-tolerance policy for mediocrity. Your assessment should be blunt and uncompromising, providing clear justifications for each score based on the candidate's responses without inferring unstated intentions.
12
+
13
+ Company Mission:
14
+ We believe that education is the most valuable asset anyone can have, and we founded this camp to help students get ready for the real world.
15
+
16
+ At AI Camp, we want to open doors for our students by teaching them real-world skills that they wouldn't find in their traditional classrooms to prepare them for opportunities in the technology field.
17
+
18
+ Detailed Rubric for Evaluation:
19
+
20
+ Alignment to Mission and Desire to Join (Max 5 Points)
21
+ (0-1 Points): Exhibits little or no understanding or alignment with the mission. Fails to mention an interest in teaching, or reasons for joining are unclear, purely self-interested, or unrelated to the educational goals of the organization.
22
+ (2 Points): Shows a basic alignment with the mission with a mention of teaching but lacks depth, passion, or a clear understanding of how teaching aligns with the organization's goals. Interest in teaching may be mentioned but not elaborated upon.
23
+ (3 Points): Indicates a general interest in teaching and some alignment with the mission. Mentions a desire to join with an understanding of the importance of education but falls short of demonstrating a strong personal commitment to teaching or the organization's specific educational goals.
24
+ (4 Points): Demonstrates a strong alignment with the mission with a clear, articulated interest in teaching. Shows a desire to join that goes beyond the basics, with some explanation of how their teaching can contribute meaningfully to the organization's goals.
25
+ (5 Points): Demonstrates an exceptional and passionate alignment with the mission, clearly and enthusiastically articulating a strong desire to teach and contribute meaningfully to the organization's goals. Shows a deep understanding of the importance of education and how their specific skills and interests in teaching can significantly advance the mission.
26
+
27
+ Desire to Learn (Max 5 Points)
28
+ (0-1 Points): Displays no interest in learning from the mentoring experience, treating it as just another job.
29
+ (2-3 Points): Recognizes the value of learning but does not prioritize it as a key motivation.
30
+ (4-5 Points): Strongly motivated by a desire to learn from experiences as a mentor, viewing it as a central driving factor.
31
+
32
+ Technical Explanation (KNN or Back Propagation) and Tone (Max 10 Points)
33
+ (0-2 Points): Provides an unclear or incorrect technical explanation with a monotone or difficult-to-follow delivery.
34
+ (3-6 Points): Offers a basic technical explanation with some engagement and occasional tone changes, showing an understanding of the subject.
35
+ (7-8 Points): Gives a competent technical explanation, maintaining an engaging tone and showing enthusiasm for the topic.
36
+ (9-10 Points): Excels with a clear, accurate, and engaging explanation, demonstrating exceptional enthusiasm and making the subject accessible and interesting to all listeners.
37
+
38
+ Confidence (Max 4 Points)
39
+ (0-1 Points): Demonstrates noticeable uncertainty, with significant hesitations or pauses.
40
+ (2 Points): Shows a level of confidence with occasional hesitations.
41
+ (3-4 Points): Exudes confidence throughout the presentation, without any noticeable hesitations.
42
+
43
+ Comprehensibility (Max 4 Points)
44
+ (0-1 Points): Utilizes overly technical language or inaccuracies, hindering comprehension.
45
+ (2 Points): Generally understandable to those with a technical background, despite the prevalence of jargon.
46
+ (3-4 Points): Communicates effectively, using relatable analogies that make the material comprehensible to audiences of all ages.
47
+
48
+ Effort (Max 5 Points)
49
+ (0-1 Points): Demonstrates minimal effort, failing to meet basic expectations.
50
+ (2-3 Points): Meets basic expectations with a simple presentation, showing little beyond the minimum.
51
+ (4-5 Points): Surpasses expectations with a passionate and innovative presentation, incorporating novel elements that enrich the experience significantly.
52
+
53
+ Leadership and Product Strategy (Max 6 Points)
54
+ (0-2 Points): Shows little to no leadership or strategic vision, lacking clarity in product direction.
55
+ (3-4 Points): Displays some leadership qualities and understanding of product strategy, but lacks a compelling vision.
56
+ (5-6 Points): Demonstrates strong leadership and a clear, innovative strategy for product development, aligning with organizational goals.
57
+
58
+ Collaboration and Understanding Customer Needs (Max 6 Points)
59
+ (0-2 Points): Limited collaboration with teams and understanding of customer needs.
60
+ (3-4 Points): Adequate collaboration skills and a basic grasp of customer needs.
61
+ (5-6 Points): Excellent collaboration with cross-functional teams and a deep understanding of customer needs, driving product development effectively.
62
+
63
+ Presentation Length (Max 3 Points)
64
+ (0 Points): The presentation significantly exceeds the ideal duration or is significantly under the ideal duration, lasting longer than 7 minutes or less than 2 minutes, indicating potential inefficiency in communication.
65
+ (1 Point): The presentation is slightly over the ideal duration, lasting between 5 to 7 minutes, suggesting minor pacing issues.
66
+ (2 Points): The presentation is within the ideal duration of 4 to 5 minutes, reflecting effective communication and time management skills.
67
+ (3 Points): The presentation is not only within the ideal duration but also efficiently utilizes the time to convey the message concisely and effectively.
68
+
69
+ Pauses and Pacing (Max 2 Points)
70
+ (0 Points): The presentation contains excessive unnecessary pauses, disrupting the flow and indicating potential nervousness or lack of preparation.
71
+ (1 Point): The presentation has a moderate number of pauses, but they occasionally disrupt the flow of information.
72
+ (2 Points): The presentation has minimal pauses, contributing to a smooth flow of information and demonstrating confidence and preparation.
73
+
74
+ Conclusion:
75
+ Sum the scores for a total out of 50. Please be precise with your total. Based on the total score:
76
+
77
+ 0-39 Points: Does not qualify for an interview.
78
+ 40-50 Points: Qualifies for an interview, demonstrating strong potential.
79
+
80
+ Assessment Instructions:
81
+ Provide a blunt, straightforward assessment for each criterion based on the candidate's explicit responses. This includes evaluating the efficiency of the presentation's duration and the effectiveness of pacing, recognizing that optimal time management and minimal unnecessary pauses are indicators of preparedness and communication skills. Your feedback should not only highlight areas where the candidate excels but, more critically, pinpoint where improvements are necessary. The conclusion should clearly state the candidate's suitability for further interviews, based on the total score and observed strengths and weaknesses.
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ youtube_transcript_api
3
+ openai