From 1f87c3c87ae8c4c34fcaab2085a4ce4a058e7544 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 20 Oct 2024 11:20:22 +0530 Subject: [PATCH] Edit book: A new tool to create audio narration of all text in the book using Text-to-speech --- src/calibre/ebooks/oeb/polish/tts.py | 1 + src/calibre/gui2/tweak_book/tts.py | 2 ++ src/calibre/gui2/tweak_book/ui.py | 3 +++ 3 files changed, 6 insertions(+) diff --git a/src/calibre/ebooks/oeb/polish/tts.py b/src/calibre/ebooks/oeb/polish/tts.py index c08f4efcad..1c073e2409 100644 --- a/src/calibre/ebooks/oeb/polish/tts.py +++ b/src/calibre/ebooks/oeb/polish/tts.py @@ -534,6 +534,7 @@ def embed_tts(container, report_progress=None, callback_to_download_voices=None) html_item.set('media-overlay', smilitem.get('id')) duration_map[smilitem.get('id')] = file_duration container.set_media_overlay_durations(duration_map) + return True def develop(): diff --git a/src/calibre/gui2/tweak_book/tts.py b/src/calibre/gui2/tweak_book/tts.py index 7cef350cb2..a6946a040b 100644 --- a/src/calibre/gui2/tweak_book/tts.py +++ b/src/calibre/gui2/tweak_book/tts.py @@ -196,6 +196,8 @@ def develop(): outpath = b + '-tts' + e container.commit(outpath) print('Output saved to:', outpath) + else: + print('Failed') del d del app diff --git a/src/calibre/gui2/tweak_book/ui.py b/src/calibre/gui2/tweak_book/ui.py index e4bbda5ebe..2c8bc5a208 100644 --- a/src/calibre/gui2/tweak_book/ui.py +++ b/src/calibre/gui2/tweak_book/ui.py @@ -468,6 +468,8 @@ class Main(MainWindow): self.action_get_ext_resources = treg('download-metadata.png', _('Download external &resources'), self.boss.get_external_resources, 'get-external-resources', (), _( 'Download external resources in the book (images/stylesheets/etc/ that are not included in the book)')) + self.action_embed_tts = treg('bullhorn.png', _('Add Text-to-speech narration'), self.boss.embed_tts, 'embed-tts', (), _( + 'Add audio narration for all the book text using Text-to-speech generation')) def ereg(icon, text, target, sid, keys, description): return reg(icon, text, partial(self.boss.editor_action, target), sid, keys, description) @@ -639,6 +641,7 @@ class Main(MainWindow): e.addAction(self.action_transform_styles) e.addAction(self.action_transform_html) e.addAction(self.action_fix_html_all) + e.addAction(self.action_embed_tts) e.addAction(self.action_pretty_all) e.addAction(self.action_rationalize_folders) e.addAction(self.action_add_cover)