Skip to content

Commit 7117960

Browse files
committed
Some files have been modified and Project is complete now
1 parent 3092ccb commit 7117960

File tree

4 files changed

+33
-52
lines changed

4 files changed

+33
-52
lines changed

sampleVideo.mp4

27.2 MB
Binary file not shown.

subtitleGenerator.py

+33-8
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,36 @@ def generate_conversation_object(file_type, location):
4545

4646
def generate_output_file(conv_obj, output_filename):
4747

48-
err_hour = int(conv_obj.get_messages().messages[0].start_time.hour) #these values are not part of file
48+
#these value are errors ... or not part of timestamps
49+
err_hour = int(conv_obj.get_messages().messages[0].start_time.hour) #these values are not part of time stamps
4950
err_minute = int(conv_obj.get_messages().messages[0].start_time.minute)
5051
err_second = int(conv_obj.get_messages().messages[0].start_time.second)
5152

52-
print(err_hour,err_minute,err_second)
5353

54+
#This will generate simple .srt file with default timestamps
55+
# with open(output_filename, 'w') as f:
56+
# sequence_number = 1
57+
# for data in conv_obj.get_messages().messages:
58+
# f.write(f'{str(sequence_number)}\n')
59+
# s_hour = int(data.start_time.hour)
60+
# e_hour = int(data.end_time.hour)
61+
62+
# s_minute = int(data.start_time.minute)
63+
# e_minute = int(data.end_time.minute)
64+
65+
# s_second = int(data.start_time.second)
66+
# e_second = int(data.end_time.second)
67+
68+
# f.write(f'{s_hour}:{s_minute}:{s_second} --> {e_hour}:{e_minute}:{e_second}\n')
69+
70+
# f.write(f'{data.text}\n\n')
71+
# sequence_number += 1
72+
73+
# print("Task Complete..Subtitle File Has Been Created")
74+
75+
76+
#To make make our output more accurate we have subtract error timestamps from the default timestamps
77+
#this will generate the more accurate subtitle file
5478
with open(output_filename, 'w') as f:
5579
sequence_number = 1
5680
for data in conv_obj.get_messages().messages:
@@ -65,27 +89,28 @@ def generate_output_file(conv_obj, output_filename):
6589
e_second = int(data.end_time.second)
6690

6791
f.write(f'{s_hour-err_hour}:{s_minute-err_minute}:{s_second-err_second} --> {e_hour-err_hour}:{e_minute-err_minute}:{e_second-err_second}\n')
68-
print(data.text)
6992
f.write(f'{data.text}\n\n')
7093
sequence_number += 1
71-
72-
print("Take Complete..Subtitle File Is Created")
94+
print("Task Complete..Subtitle File Has Been Created")
95+
7396

7497
def main():
7598
file_type = args.filetype
7699
location = args.locate
77100
output_filename = args.output
78-
print(file_type,location,output_filename)
101+
print("Filetype -->",file_type)
102+
print("File location -->",location)
103+
print("Outputfile name -->",output_filename)
79104

80105
filetype_list = ['audio','video','Audio','Video']
81106

82107
if(file_type in filetype_list):
83-
conversation_object = generate_conversation_object(file_type.capitalize(), location) #function call to create a conversation object
108+
conversation_object = generate_conversation_object(file_type.capitalize(), location) #method call to create a conversation object
84109
else:
85110
print("filetype is not audio/video")
86111
exit()
87112

88-
generate_output_file(conversation_object, output_filename) #function call to generate subtitle file
113+
generate_output_file(conversation_object, output_filename) #method call to generate subtitle file
89114

90115

91116
if __name__=="__main__":

videofile.mp4

-7.16 MB
Binary file not shown.

videofile.srt

-44
This file was deleted.

0 commit comments

Comments
 (0)