1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add support for espeak-ng. Closes #42438

This commit is contained in:
Marcos Alano 2018-07-10 15:00:25 -03:00 committed by Brian Coca
parent 824524c67a
commit 2d6bb2500e

View file

@ -32,7 +32,7 @@ options:
description: description:
What voice to use What voice to use
required: false required: false
requirements: [ say or espeak ] requirements: [ say or espeak or espeak-ng ]
author: author:
- "Ansible Core Team" - "Ansible Core Team"
- "Michael DeHaan (@mpdehaan)" - "Michael DeHaan (@mpdehaan)"
@ -68,17 +68,18 @@ def main():
msg = module.params['msg'] msg = module.params['msg']
voice = module.params['voice'] voice = module.params['voice']
possibles = ('say', 'espeak', 'espeak-ng')
executable = module.get_bin_path('say') if get_platform() != 'Darwin':
if not executable:
executable = module.get_bin_path('espeak')
elif get_platform() != 'Darwin':
# 'say' binary available, it might be GNUstep tool which doesn't support 'voice' parameter # 'say' binary available, it might be GNUstep tool which doesn't support 'voice' parameter
voice = None voice = None
module.warn("'say' executable found but system is '%s': ignoring voice parameter" % get_platform())
if not executable: for possible in possibles:
module.fail_json(msg="Unable to find either 'say' or 'espeak' executable") executable = module.get_bin_path(possible)
if executable:
break
else:
module.fail_json(msg='Unable to find either %s' % ', '.join(possibles))
if module.check_mode: if module.check_mode:
module.exit_json(msg=msg, changed=False) module.exit_json(msg=msg, changed=False)