So in essence, we start to build a sentence with a fixed start time. The start time is only advanced once we know that a sentence has been completed. If no start time exists, it is simply a new dictionary entry. If the start time exists, data is added to the entry for that time but the end_time is updated at the same time, so the end time advances with the text. The idea is to build a dictionary based on start_times. I have re-coded to rely on the pysrt package, as requested, and a smigeon of re. Je rappelle la définition de ce qu'est un produit scalaire, dot product dans Ⅎ.ĭonc je prends deux vecteurs dans Ⅎ et je définis cette opération-là , linéaire, u Here you may download more videos and their respective subtitle files: Edit 3 4 sub = pysrt.open('video.srt')Ĭharacters_per_second = sub.characters_per_secondįor j,character in enumerate(" ".join(text.split())):Ĭharacter_duration = len(character)*characters_per_secondĭict_subtitle = Here is a code to create a dictionary which stores character, character_duration (average over subtitle), and start or end original time stamb, if it exists for this character. This could be used to cross-check and adjust timing accordingly. The exact timing for words starting or ending an original subtitle is known. The full sample video can be downloaded here: Īttention: The subtitle file will be overridden, so you might want to store a copy with another name to be able to compare. This might not seem like much in the beginning, but as the video gets longer, the difference increases. Our friends." As a teacher, I've internalized this message.Īs you can see the original last time stamp is 00:00:29,800 whereas in the output file it is 00:00:29,859. )): 0Ĭivil Rights Movement, states, "In the end, we will remember not the words of our enemies but the silence of our friends. ![]() The output looks like this (yes, there is still some work to do on the sentence recognition par (i.e. We will remember not the words of our enemiesĪs a teacher, I've internalized this message.Ĭonvert_subtitle_one_sentence("test.srt") # Check if there is a non-sentence remaining at the end # Store the sentence together with the time it takes to say the sentenceĭict_times_sentences_subtitle = Time_sentence += dict_times_word_subtitle # Compute the time it takes to speak the sentenceįor j in range(last_number_of_words, last_number_of_words + number_of_words): Total_number_of_words = len(dict_times_word_subtitle.keys())Įntire_text += dict_times_word_subtitle +" "įor i,sentence in enumerate(re.findall(r'(*)', entire_text)): # Store Each Sentence and the Average Time to Say it in a Dictionary Time = len(word+" ")/characters_per_secondĭict_times_word_subtitle = # Store Each Word and the Average Time (seconds) it Takes to Say in a Dictionaryįor j,word in enumerate(subtitle_text.split()): Subtitle_duration = (bine(date.min, _time()) - datetime.min).total_seconds()Ĭharacters_per_second = len(subtitle_text)/subtitle_duration # Store Each Word and the Average Time it Takes to Say it in a dictionary
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |