diff --git a/audiblez.py b/audiblez.py index c2515e1..71c6576 100755 --- a/audiblez.py +++ b/audiblez.py @@ -28,6 +28,11 @@ VOICES_FILE = 'voices.json' config.MAX_PHONEME_LENGTH = 128 +def print_eta(total_chars, processed_chars, chars_per_sec): + remaining_time = (total_chars - processed_chars) / chars_per_sec + print(f'Estimated time remaining: {strfdelta(remaining_time)}') + + def main(kokoro, file_path, lang, voice, pick_manually, speed, providers): # Set ONNX providers if specified if providers: @@ -68,6 +73,7 @@ def main(kokoro, file_path, lang, voice, pick_manually, speed, providers): print('Started at:', time.strftime('%H:%M:%S')) print(f'Total characters: {total_chars:,}') print('Total words:', len(' '.join(texts).split())) + print_eta(total_chars, processed_chars, 20) # assume 20 chars per second at the beginning chapter_mp3_files = [] durations = {} @@ -93,9 +99,7 @@ def main(kokoro, file_path, lang, voice, pick_manually, speed, providers): delta_seconds = end_time - start_time chars_per_sec = len(text) / delta_seconds processed_chars += len(text) - remaining_chars = total_chars - processed_chars - remaining_time = remaining_chars / chars_per_sec - print(f'Estimated time remaining: {strfdelta(remaining_time)}') + print_eta(total_chars, processed_chars, chars_per_sec) print('Chapter written to', chapter_filename) print(f'Chapter {i} read in {delta_seconds:.2f} seconds ({chars_per_sec:.0f} characters per second)') progress = processed_chars * 100 // total_chars @@ -189,14 +193,14 @@ def create_m4b(chapter_files, filename, title, author, cover_image): 'ffmpeg', '-i', f'{tmp_filename}', '-i', 'chapters.txt', - # '-map', '0', - # '-map_metadata', '1', - *cover_image_args, + '-map', '0', + '-map_metadata', '1', + # *cover_image_args, '-c:a', 'copy', '-c:v', 'copy', '-disposition:v', 'attached_pic', - '-metadata:s:v', f'title={title}', - '-metadata', f'artist={author}', + # '-metadata:s:v', f'title={title}', + # '-metadata', f'artist={author}', '-c', 'copy', '-f', 'mp4', f'{final_filename}'