This commit is contained in:
Kovid Goyal 2025-08-08 11:34:37 +05:30
commit 9e241d01ed
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -234,11 +234,18 @@ def available_engines() -> dict[str, EngineMetadata]:
), True) ), True)
elif x == 'speechd': elif x == 'speechd':
continue continue
try:
import calibre_extensions.piper
except ImportError:
pass
else:
ans['piper'] = EngineMetadata('piper', _('The Piper Neural Engine'), _( ans['piper'] = EngineMetadata('piper', _('The Piper Neural Engine'), _(
'The "piper" engine can track the currently spoken sentence on screen. It uses a neural network ' 'The "piper" engine can track the currently spoken sentence on screen. It uses a neural network '
'for natural sounding voices. The neural network is run locally on your computer, it is fairly resource intensive to run.' 'for natural sounding voices. The neural network is run locally on your computer, it is fairly resource intensive to run.'
), TrackingCapability.Sentence, can_change_pitch=False, voices_have_quality_metadata=True, has_managed_voices=True, ), TrackingCapability.Sentence, can_change_pitch=False, voices_have_quality_metadata=True, has_managed_voices=True,
has_sentence_delay=True) has_sentence_delay=True)
if islinux: if islinux:
try: try:
from speechd.paths import SPD_SPAWN_CMD from speechd.paths import SPD_SPAWN_CMD
@ -322,7 +329,12 @@ def create_tts_backend(force_engine: str | None = None, config_name: str = CONFI
if not available_engines(): if not available_engines():
raise OSError('There are no available TTS engines. Install a TTS engine before trying to use Read Aloud, such as flite or speech-dispatcher') raise OSError('There are no available TTS engines. Install a TTS engine before trying to use Read Aloud, such as flite or speech-dispatcher')
prefs = load_config(config_name) prefs = load_config(config_name)
engine_name = prefs.get('engine', '') if force_engine is None else force_engine if force_engine is not None:
engine_name = force_engine
if engine_name not in available_engines():
raise OSError(f'TTS engine {force_engine} is not available.')
else:
engine_name = prefs.get('engine', '')
engine_name = engine_name or default_engine_name() engine_name = engine_name or default_engine_name()
if engine_name not in available_engines(): if engine_name not in available_engines():
engine_name = default_engine_name() engine_name = default_engine_name()