View Single Post
Old 06-17-2018, 10:26 AM   #1
jackie_w
Grand Sorcerer
jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.jackie_w ought to be getting tired of karma fortunes by now.
 
Posts: 6,212
Karma: 16534894
Join Date: Sep 2009
Location: UK
Device: Kobo: KA1, ClaraHD, Forma, Libra2, Clara2E. PocketBook: TouchHD3
[GUI Plugin] TTS to MP3: Create MP3 audiobook using Windows TTS

*** May 15, 2022
Unfortunately, due to issues at home, I will no longer be providing ongoing support for this plugin. Hopefully the latest version will work OK in calibre v5.xx and the upcoming calibre v6.xx
*** Feb 2024: Still working OK in calibre v7.xx
***


Purpose: This plugin can record a set of audiobook MP3 files for a non-DRM ebook in your calibre library. For most retail fiction ebooks this is likely to equate to one MP3 per chapter. The selected book needs to be available in EPUB, AZW3 or KEPUB format.

Notes:
  • The plugin uses Microsoft's built-in SAPI5 Text-to-Speech (TTS) software and Voices, therefore only available for Windows users.
  • See post #2 for more detail about which Voices will be visible to this plugin.
  • TTS to MP3 v0.5.4 will only run on calibre v5.4 or above. If you are running an earlier version of calibre, v3.41-5.3 inclusive, please see post #2 which contains a zip for TTS to MP3 v0.4.1 which you can install manually.

Pros: Free. Can be played on any MP3 player or smartphone app. No waiting for a publisher to decide if/when an audiobook will be available.
Cons: Obviously, automated TTS is not as good as a reading by a good professional voice artiste.

Background: The original idea came from Doitsu's Sigil plugin, Windows TTS output. This was a fun project for me which provided a personal challenge to create a plugin which can run in the background. I'm sharing it here with Doitsu's permission.

Features: See first attached screenshot for main GUI screen.
  • Allows you to select which of the ebook's content files you want to create MP3s from. Useful if you don't want an MP3 for front- and backmatter pages.
  • The file selection GUI (see second attached screenshot) also contains a Voice Tester feature so you can easily try out the various voices installed on your PC. You can use text from your selected book or copy/paste your own sample text for the Voice Tester.
  • Uses metadata from the book and calibre library for the MP3 tags and filenames. Some user choice provided.

How to install: Preferences - Get plugins to enhance calibre Select TTS to MP3 then press Install

How to use:
Spoiler:
  • Select a single non-DRM'd book in calibre (EPUB, AZW3 or KEPUB)
  • Select TTS to MP3 from whichever calibre toolbar/menu you added it to.
  • See first screenshot. Select the files to be recorded using either the [All] or [Manual Select] button. The latter will open a new dialog (see second screenshot) showing a list of available files with their wordcount and TOC title (if any). You can see the whole text content of any file by clicking it. Alternatively, you can see a tooltip preview of the beginning of any file by hovering the mouse over its HTML filename.
  • Play with the Voice Tester if required, then [Save] the list of files to be recorded to MP3. If you changed the Voice Name and/or Rate, they will also be transferred to the main screen.
  • Adjust the MP3 tag options for Artist/Album/Genre/Year if required. Each tag box is editable so, if you don't like any of the options on offer, just type your own value.
  • Click the [Create MP3s] button and choose a destination directory for the new MP3s.
  • The MP3s will be created as a background task leaving you free to get on with other things. You can check ongoing progress by clicking the [Jobs:n] button in the bottom-right corner of the calibre window. When all MP3s are complete you will see a standard calibre notification pop-up appear in the bottom-right corner.

Configuration: See third attached screenshot.
Spoiler:
  • Default Voice & Speech rate: Hopefully self-explanatory. See post #2 below for more details about Voices.
  • Cover thumbnail: Embed a small cover thumbnail in every MP3 or copy thumbnail once to selected MP3 directory (as cover.jpg). Use if disk space is an issue.
  • Image alternate text (experimental): Some publishers provide a description of each image in each <img alt="Helpful description here".../>. If this alt-text exists you can choose to have the contents read aloud or not.

    I've included this experimental feature following discussion in this recent thread where it became clear that all of the popular Android TTS-enabled reading apps tested completely ignore this descriptive text.
    Caveat: Some publisher-provided alt-text descriptions are not at all helpful to users. You will need to decide whether to enable this on a book-by-book basis.


Testing: All testing was done on a Windows 10 x64 PC running calibre x64 and using voices of various dialects of English. The plugin may work on Windows 8 but I'm not sure.

Credits: Thanks to Doitsu for the original Sigil work and for beta-testing. Thanks to chye who didn't hang around MobileRead for long but did create a TTS plugin for the calibre Viewer. This code was very helpful. Thanks, as always, to kovidgoyal for fast help with technical issues. The plugin uses LAME for generating MP3 files.

Version History:
Spoiler:
  • Version 0.6.0: 15 May 2022
    Maintenance upgrade for PyQt6/calibre6 compatibility.
  • Version 0.5.9: 26 March 2021
    Bug fix: Stop plugin crashing when config set to embed cover thumbnail in each MP3 but book has no cover
  • Version 0.5.8: 22 November 2020
    • Fix: saving MP3s to a user-selected directory containing unicode characters
    • Fix: processing multiple books simultaneously
  • Version 0.5.5: 16 November 2020
    Make plugin more reliable by no longer looking for the Windows default Voice at calibre start up.
  • Version 0.5.4: 28 October 2020
    • Maintenance update for compatibility with calibre v5.4 and above.
      N.B. This update will not run at all on calibre versions <v5.4.
      • Existing users of this plugin who have not yet updated to calibre v5.4 do not need to do anything.
      • Anyone needing a new copy of TTS to MP3 v0.4.x, which runs on calibre versions v3.41-v5.3 (inclusive) will find it attached at the end of post #2 of this thread. It will need to be installed manually via the standard calibre option, 'Load plugin from file'.
    • Calibre 64-bit users: No change to functionality.
    • Calibre 32-bit users, including Calibre Portable: Should see an added benefit. You will now have access to all Voices installed in the 32-bit section of your Windows registry rather than just a single default Voice.
      After updating the plugin you do not need to do anything special. All available Voices should automatically appear in the relevant drop-down menus. See post #2 of this thread for more technical detail.
  • Version 0.4.0: 03 May 2020
    • Maintenance upgrade for python3 compatibility.
    • Plugin icon updated to be more visible when using calibre's Dark mode.
  • Version 0.1.3: 3 November 2018
    Small change to enable plugin to be listed in calibre's Index of Plugins.

    Plus ... plugin should now work in a limited fashion for Windows/calibre 32bit users, including Calibre Portable.
    This limitation is that only a single default MS Voice will be available for selection.
    All other features should work the same as for Windows/calibre 64bit users.
  • Version 0.1.1: 18 June 2018
    Will not currently run on 32-bit Windows/calibre. This includes calibre Portable. On 32-bit, this version will fail in a slightly more graceful way.
  • Version 0.1.0: 17 June 2018 - Initial release
Attached Thumbnails
Click image for larger version

Name:	main.jpg
Views:	2772
Size:	78.0 KB
ID:	164499   Click image for larger version

Name:	select_files.jpg
Views:	2569
Size:	153.3 KB
ID:	164500   Click image for larger version

Name:	config.jpg
Views:	2351
Size:	57.5 KB
ID:	164501  
Attached Files
File Type: zip TTS to MP3_v0-6-0.zip (412.9 KB, 36026 views)

Last edited by jackie_w; 02-16-2024 at 08:18 AM. Reason: Added note re: calibre v7
jackie_w is offline   Reply With Quote