-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspeak
executable file
·73 lines (65 loc) · 1.72 KB
/
speak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env fish
# speak - Speak text using a text-to-speech engine.
argparse -n speak --ignore-unknown 'h/help' 'i/stdin' 'o/output=' 'e/engine=' -- $argv
if test -n "$_flag_h"
echo "speak - Speak text using a text-to-speech engine."
echo "Usage: speak [arguments] [text]"
echo
echo " -h/--help - Print help and exit."
echo " -/-i/--stdin - Read text from stdin."
echo " -o/--output - Write output to a file instead of playing."
echo " -e/--engine - Select a specific engine (provide without selection to list available)"
exit
end
set engines espeak say flite
set engine "$_flag_e"
if test -z "$engine"
for i in $engines
if command -qs "$i"
set engine "$i"
break
end
end
if test -z "$engine"
echo "speak: no supported engine available"
exit 1
end
else
if not contains "$engine" $engines
echo "speak: unknown engine \"$engine\""
exit 1
end
end
set stdin 0
set d_idx (contains -i -- - $argv)
if test -n "$_flag_i"; or test -n "$d_idx"
set stdin 1
if test -n "$d_idx"
set -e argv[$d_idx]
end
end
if test "$engine" = 'espeak'
set extra
if test $stdin = 1
set -a extra '--stdin'
end
if test -n "$_flag_o"
set -a extra -w "$_flag_o"
end
espeak $extra $argv
else if test "$engine" = 'say'
if test $stdin = 1; or test -n "$_flag_o"
echo "speak: error: --stdin and --output are not yet implemented for macOS."
exit 1
end
say $argv
else if test "$engine" = 'flite'
set extra
if test $stdin = 1
set -a extra -f -
end
if test -n "$_flag_o"
set -a extra -o "$_flag_o"
end
flite $extra -t "$argv"
end