Add completion script for MacOS Speech Synthesis manager (say)

This commit is contained in:
Daniel Teunis 2018-10-03 03:09:10 +02:00
parent 09ab969e20
commit d2ead6e81b
1 changed files with 68 additions and 0 deletions

68
src/_say Normal file
View File

@ -0,0 +1,68 @@
#compdef say
# ------------------------------------------------------------------------------
# Copyright (c) 2018 zsh-users - http://github.com/zsh-users
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for the MacOS Speech Synthesis manager (man 1 say).
#
# ------------------------------------------------------------------------------
# Author
# -------
#
# * Daniel Teunis <daniel@teunis.cc>
#
# ------------------------------------------------------------------------------
__voice_list ()
{
say --voice="?" | awk '/ [a-z]+/ {print $1} '
}
__file_format_list ()
{
say --file-format="?" | awk ' {print $1} '
}
_arguments \
'(-f --input-file)'{-f,--input-file=}'[specifies a file to be spoken]:inputfile:_files' \
'(-v --voice)'{-v,--voice=}'[specifies a voice to be used]:voice:->voice' \
'(-r --rate)'{-r,--rate=}'[specifies the speech rate to be used (words per minute)]:rate' \
'(-o --output-file)'{-o,--output-file=}'[specifies the path for an audio file to be written]:outputfile' \
'(-n --network-send)'{-n,--network-send=}'[specifies a service name or IP port to be used]:nwsend' \
'(-a --audio-device)'{-a,--audio-device=}'[specifies the audio device by ID or name prefix]:audiodevice' \
'(--progress)'--progress'[enables progress meter]:progress' \
'(-i --interactive)'{-i,--interactive}'[enables interactive mode]:interactive' \
'(--file-format)'--file-format='[specifies the format of the file to write]:module fileformat:->fileformat' \
'(--data-format)'--data-format='[specifies the format of the audio data to be stored]:dataformat' \
'(--channels)'--channels='[specifies the number of channels]:channels' \
'(--bit-rate)'--bit-rate='[specifies the bit rate]:bitrate' \
'(--quality)'--quality='[specifies the quality level between 0 (lowest) and 127]:quality'
case "$state" in
voice)
compadd `__voice_list`
;;
fileformat)
compadd `__file_format_list`
;;
esac