forked from isyedahmed531/Automated-Interview-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.py
More file actions
62 lines (39 loc) · 1.73 KB
/
Copy pathprocess.py
File metadata and controls
62 lines (39 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import os
from moviepy.editor import VideoFileClip
import transcribe # Assuming you have your transcribe module defined
import semantic # Assuming you have your semantic module defined
# from emotion_detection import get_emotions
from emotion_analysis import get_emotions
def process_files(correct_answers):
output_folder = 'output_folder'
# video_files = [file for file in os.listdir(output_folder) if file.startswith('trimmed_part')]
audio_files = [file for file in os.listdir(output_folder) if file.startswith('audio_part')]
# correct_answers = [
# "white color",
# "dream destination northern areas",
# "anything",
# "I don't want superpower",
# "favorite book"
# ]
result = []
emotions = get_emotions("output.mp4")
# Process video files
for audio_file, correct_ans in zip(audio_files, correct_answers):
answer = {}
# Process audio transcript and semantic similarity
audio_path = os.path.join(output_folder, audio_file)
transcript = transcribe.transcribe_video(audio_path)
if transcript is None:
transcript = ""
answer["TranscribedAnswer"] =transcript
sentence_embedding_function = semantic.load_word_embeddings()
similarity_percentage = semantic.calculate_semantic_similarity(transcript, correct_ans, sentence_embedding_function)
#ans_result = f"Answer for Q{question_count} is correct: {str(answer)}"
answer["AnswerCorrectness"] = f"{similarity_percentage:.2f}%"
# if ans_result is None:
# ans_result = ""
result.append(answer)
# with open("result.txt", "w") as file:
# file.write(result)
# return result
return emotions, result