@@ -45,12 +45,36 @@ def generate_conversation_object(file_type, location):
45
45
46
46
def generate_output_file (conv_obj , output_filename ):
47
47
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
49
50
err_minute = int (conv_obj .get_messages ().messages [0 ].start_time .minute )
50
51
err_second = int (conv_obj .get_messages ().messages [0 ].start_time .second )
51
52
52
- print (err_hour ,err_minute ,err_second )
53
53
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
54
78
with open (output_filename , 'w' ) as f :
55
79
sequence_number = 1
56
80
for data in conv_obj .get_messages ().messages :
@@ -65,27 +89,28 @@ def generate_output_file(conv_obj, output_filename):
65
89
e_second = int (data .end_time .second )
66
90
67
91
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 )
69
92
f .write (f'{ data .text } \n \n ' )
70
93
sequence_number += 1
71
-
72
- print ( "Take Complete..Subtitle File Is Created" )
94
+ print ( "Task Complete..Subtitle File Has Been Created" )
95
+
73
96
74
97
def main ():
75
98
file_type = args .filetype
76
99
location = args .locate
77
100
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 )
79
104
80
105
filetype_list = ['audio' ,'video' ,'Audio' ,'Video' ]
81
106
82
107
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
84
109
else :
85
110
print ("filetype is not audio/video" )
86
111
exit ()
87
112
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
89
114
90
115
91
116
if __name__ == "__main__" :
0 commit comments