mirror of
https://github.com/rany2/edge-tts
synced 2024-11-22 01:45:02 +00:00
Update convenience script
This commit is contained in:
parent
fd9e8c04e8
commit
ed981ee6e5
@ -1,39 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
unset stdin
|
||||||
## To use this script you need to install edge-tts.py to a directory in your $PATH as executable
|
|
||||||
## and give it the name edge-tts. Alternatively you could just run the install script.
|
|
||||||
export LC_ALL=C
|
|
||||||
|
|
||||||
## We use a temporary file now instead of file descriptor because mpg123 doesn't
|
|
||||||
## let me seek back a file descriptor, only seek forward.
|
|
||||||
ttsmpeg=$(mktemp)
|
|
||||||
|
|
||||||
## Cleanup function to kill all processes and remove tmp file
|
|
||||||
quitfunc() {
|
|
||||||
kill -- $(jobs -p)
|
|
||||||
rm -f -- "${ttsmpeg:?}"
|
|
||||||
}
|
|
||||||
trap 'quitfunc > /dev/null 2>&1' EXIT
|
|
||||||
|
|
||||||
## If stdin is $1 we shift 1 and save the stdin data to an stdin variable.
|
|
||||||
## We also add --file=/dev/stdin to params that edge-tts will get.
|
|
||||||
if [ "$1" == "stdin" ]
|
if [ "$1" == "stdin" ]
|
||||||
then
|
then
|
||||||
stdin=$(cat)
|
stdin=$(cat)
|
||||||
shift 1
|
shift 1
|
||||||
set -- "$@" '--file=/dev/stdin'
|
edge-tts -f <(printf '%s' "$stdin") | mpv -
|
||||||
else
|
else
|
||||||
stdin=""
|
edge-tts "$@" | mpv -
|
||||||
fi
|
fi
|
||||||
edge-tts "${@}" >"$ttsmpeg" <<<"$stdin" &
|
|
||||||
edgePID=$!
|
|
||||||
|
|
||||||
## Wait until temporary file has some data so mpg123 doesn't exit immediately
|
|
||||||
## because it thinks file is empty and won't have any data.
|
|
||||||
##
|
|
||||||
## kill -0 checks if PID is still running.
|
|
||||||
while kill -0 "$edgePID" 2>/dev/null && [ "$(wc -c < "$ttsmpeg")" == 0 ]
|
|
||||||
do
|
|
||||||
sleep 0.1
|
|
||||||
done
|
|
||||||
mpg123 --quiet --control "$ttsmpeg"
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
name = edge-tts
|
name = edge-tts
|
||||||
version = 1.0.2
|
version = 1.1.0
|
||||||
author = rany
|
author = rany
|
||||||
author_email = ranygh@riseup.net
|
author_email = ranygh@riseup.net
|
||||||
description = Microsoft Edge's TTS
|
description = Microsoft Edge's TTS
|
||||||
|
@ -129,7 +129,7 @@ async def _main():
|
|||||||
)
|
)
|
||||||
parser.add_argument('-z', '--custom-ssml', help='treat text as ssml to send. For more info check https://bit.ly/3fIq13S', action='store_true')
|
parser.add_argument('-z', '--custom-ssml', help='treat text as ssml to send. For more info check https://bit.ly/3fIq13S', action='store_true')
|
||||||
parser.add_argument('-v', '--voice', help='voice for TTS. Default: en-US-AriaNeural', default='en-US-AriaNeural')
|
parser.add_argument('-v', '--voice', help='voice for TTS. Default: en-US-AriaNeural', default='en-US-AriaNeural')
|
||||||
parser.add_argument('-c', '--codec', help="codec format. Default: audio-24khz-48kbitrate-mono-mp3. Another choice is webm-24khz-16bit-mono-opus", default='audio-24khz-48kbitrate-mono-mp3')
|
parser.add_argument('-c', '--codec', help="codec format. Default: audio-24khz-48kbitrate-mono-mp3. Another choice is webm-24khz-16bit-mono-opus. For more info check https://bit.ly/2T33h6S", default='audio-24khz-48kbitrate-mono-mp3')
|
||||||
group.add_argument('-l', '--list-voices', help="lists available voices. Edge's list is incomplete so check https://bit.ly/2SFq1d3", action='store_true')
|
group.add_argument('-l', '--list-voices', help="lists available voices. Edge's list is incomplete so check https://bit.ly/2SFq1d3", action='store_true')
|
||||||
parser.add_argument('-p', '--pitch', help="set TTS pitch. Default +0Hz, For more info check https://bit.ly/3eAE5Nx", default="+0Hz")
|
parser.add_argument('-p', '--pitch', help="set TTS pitch. Default +0Hz, For more info check https://bit.ly/3eAE5Nx", default="+0Hz")
|
||||||
parser.add_argument('-r', '--rate', help="set TTS rate. Default +0%%. For more info check https://bit.ly/3eAE5Nx", default="+0%")
|
parser.add_argument('-r', '--rate', help="set TTS rate. Default +0%%. For more info check https://bit.ly/3eAE5Nx", default="+0%")
|
||||||
|
Loading…
Reference in New Issue
Block a user