diff options
author | ben | 2025-02-27 20:04:06 +0100 |
---|---|---|
committer | ben | 2025-02-27 20:04:06 +0100 |
commit | 0f09f3fbb4df6849548007de481528974ba55579 (patch) | |
tree | 92a57e619b5947f44615f11f1d3a24d4bf6ba817 /tools/speech.sh | |
parent | 703ca68f1971684b345d094ff8758eaad519e5b3 (diff) | |
download | ai_env-0f09f3fbb4df6849548007de481528974ba55579.tar.gz ai_env-0f09f3fbb4df6849548007de481528974ba55579.tar.bz2 ai_env-0f09f3fbb4df6849548007de481528974ba55579.tar.xz |
Better env usage
Diffstat (limited to 'tools/speech.sh')
-rwxr-xr-x | tools/speech.sh | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/tools/speech.sh b/tools/speech.sh index bf0a7f0..1b62fbe 100755 --- a/tools/speech.sh +++ b/tools/speech.sh @@ -15,7 +15,11 @@ done # Check for required environment variable if [[ -z "${LLM_API_KEY}" ]]; then echo "The environment variable LLM_API_KEY is not set." - echo "You can use the following command: 'export \$(xargs < ${SCRIPTPATH}/../.env)'" + echo "Try to load ${SCRIPTPATH}/../.env file" + export $(xargs <${SCRIPTPATH}/../.env) +fi +if [[ -z "${LLM_API_KEY}" ]]; then + echo "Failed to load ${SCRIPTPATH}/../.env file" exit 1 fi @@ -41,12 +45,12 @@ _choice_voice() { } # @cmd -# @flag -p --play Play the generated speech -# @option -l --lang![en|fr] Set the language -# @option -v --voice![`_choice_voice`] Set the voice -# @option -s --speed=1.0 Set the speed -# @option -f --filename=speech.wav Set the output filename -# @arg text! Set the text +# @flag -p --play Play the generated speech +# @option -l --lang![en|fr] Set the language +# @option -v --voice![`_choice_voice`] Set the voice +# @option -s --speed=1.0 Set the speed +# @option -f --filename=speech.wav Set the output filename +# @arg text! Set the text synthesize() { http_status_code=$(curl -s "${tts_host}/v1/audio/speech" -o "${argc_filename}" -w "%{http_code}" \ @@ -75,15 +79,15 @@ _choice_lang() { } # @cmd -# @option -s --source![`_choice_source`] Set the voice -# @option -f --filename=record.wav Set the output filename +# @option -s --source![`_choice_source`] Set the voice +# @option -f --filename=record.wav Set the output filename record() { parec -d "${argc_source}" --file-format=wav "${argc_filename}" } # @cmd -# @option -l --lang![`_choice_lang`] Set the language -# @option -f --filename! Set the output filename +# @option -l --lang![`_choice_lang`] Set the language +# @option -f --filename! Set the output filename transcript() { # Transcribe the specified file echo "Transcribing file ${argc_filename}, be patient" |