mirror of
https://github.com/santinic/audiblez.git
synced 2025-08-31 22:09:26 +00:00
fix
This commit is contained in:
parent
fb583a2902
commit
1f99440f37
1 changed files with 12 additions and 8 deletions
20
audiblez.py
20
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}'
|
||||
|
|
Loading…
Add table
Reference in a new issue