Add progress bar to translate trasnlations script
Browse files
translate_transcriptions.py
CHANGED
@@ -3,6 +3,7 @@ from transformers import MBartForConditionalGeneration, MBart50TokenizerFast
|
|
3 |
from lang_list import LANGUAGE_NAME_TO_CODE, WHISPER_LANGUAGES
|
4 |
import argparse
|
5 |
import re
|
|
|
6 |
|
7 |
language_dict = {}
|
8 |
# Iterate over the LANGUAGE_NAME_TO_CODE dictionary
|
@@ -45,6 +46,7 @@ def main(transcription_file, source_languaje, target_languaje, translate_model,
|
|
45 |
|
46 |
# Translate
|
47 |
translate_transcription = ""
|
|
|
48 |
for line in transcription:
|
49 |
if re.match(r"\d+$", line):
|
50 |
translate_transcription += f"{line}\n"
|
@@ -56,6 +58,7 @@ def main(transcription_file, source_languaje, target_languaje, translate_model,
|
|
56 |
translated = translate(line, source_languaje, target_languaje, translate_model, translate_tokenizer, device)
|
57 |
# translated = line
|
58 |
translate_transcription += f"{translated}\n"
|
|
|
59 |
|
60 |
# Save translation
|
61 |
output_file = f"{output_folder}/{transcription_file_name}_{target_languaje}.srt"
|
|
|
3 |
from lang_list import LANGUAGE_NAME_TO_CODE, WHISPER_LANGUAGES
|
4 |
import argparse
|
5 |
import re
|
6 |
+
from tqdm import tqdm
|
7 |
|
8 |
language_dict = {}
|
9 |
# Iterate over the LANGUAGE_NAME_TO_CODE dictionary
|
|
|
46 |
|
47 |
# Translate
|
48 |
translate_transcription = ""
|
49 |
+
progress_bar = tqdm(total=len(transcription), desc='Translating transcription progress')
|
50 |
for line in transcription:
|
51 |
if re.match(r"\d+$", line):
|
52 |
translate_transcription += f"{line}\n"
|
|
|
58 |
translated = translate(line, source_languaje, target_languaje, translate_model, translate_tokenizer, device)
|
59 |
# translated = line
|
60 |
translate_transcription += f"{translated}\n"
|
61 |
+
progress_bar.update(1)
|
62 |
|
63 |
# Save translation
|
64 |
output_file = f"{output_folder}/{transcription_file_name}_{target_languaje}.srt"
|