Make piper the default on all platforms where it is available

This commit is contained in:
Kovid Goyal 2024-09-04 22:23:28 +05:30
parent 95854ebc16
commit ea292dd2e1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -214,12 +214,12 @@ def available_engines() -> dict[str, EngineMetadata]:
), True) ), True)
elif x == 'speechd': elif x == 'speechd':
continue continue
if islinux:
if piper_cmdline(): if piper_cmdline():
ans['piper'] = EngineMetadata('piper', _('The Piper Neural Speech Engine'), _( ans['piper'] = EngineMetadata('piper', _('The Piper Neural Speech 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) ), TrackingCapability.Sentence, can_change_pitch=False, voices_have_quality_metadata=True)
if islinux:
from speechd.paths import SPD_SPAWN_CMD from speechd.paths import SPD_SPAWN_CMD
cmd = os.getenv("SPEECHD_CMD", SPD_SPAWN_CMD) cmd = os.getenv("SPEECHD_CMD", SPD_SPAWN_CMD)
if cmd and os.access(cmd, os.X_OK) and os.path.isfile(cmd): if cmd and os.access(cmd, os.X_OK) and os.path.isfile(cmd):
@ -232,12 +232,12 @@ def available_engines() -> dict[str, EngineMetadata]:
def default_engine_name() -> str: def default_engine_name() -> str:
if 'piper' in available_engines():
return 'piper'
if iswindows: if iswindows:
return 'sapi' if tweaks.get('prefer_winsapi') else 'winrt' return 'sapi' if tweaks.get('prefer_winsapi') else 'winrt'
if ismacos: if ismacos:
return 'darwin' return 'darwin'
if 'piper' in available_engines():
return 'piper'
if 'speechd' in available_engines(): if 'speechd' in available_engines():
return 'speechd' return 'speechd'
return 'flite' return 'flite'