Allow to use a plain-text transcription file as a reference #1284
+229
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the
--text_fileCLI option, which can be used to set a plain-text transcription file as a reference. It can be used for instance to generate karaoke subtitles, assuming you have the lyrics (usually available on the web).This step is performed after the alignment. It's based on the new
align_textfunction, which takes an aligned transcription result and a file path, and return an other aligned transcription result. It tries match words between synchronized transcription and plain-text transcription using the Python difflib module, acting similarly to a git diff. The diff is done on a slugified version oh each word (soHëllomatches withhellô!).Start and end-time are transferred as-is when possible, otherwise they are based on last/previous times and word lengths. Word scores are also transferred.
If the logger is set to DEBUG, it prints the details on how each word is converted, with colors to distinguish diff operations (equal / replace / insert / delete):
Here with an extract of Les filles, les meufs from french singer Marguerite.
It was quite a journey to work on this, I hope it will be useful for some people. :)