Better env usage

This commit is contained in:
ben
2025-02-27 20:04:06 +01:00
parent 703ca68f19
commit 0f09f3fbb4

View File

@@ -15,7 +15,11 @@ done
# Check for required environment variable # Check for required environment variable
if [[ -z "${LLM_API_KEY}" ]]; then if [[ -z "${LLM_API_KEY}" ]]; then
echo "The environment variable LLM_API_KEY is not set." 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 exit 1
fi fi
@@ -41,12 +45,12 @@ _choice_voice() {
} }
# @cmd # @cmd
# @flag -p --play Play the generated speech # @flag -p --play Play the generated speech
# @option -l --lang![en|fr] Set the language # @option -l --lang![en|fr] Set the language
# @option -v --voice![`_choice_voice`] Set the voice # @option -v --voice![`_choice_voice`] Set the voice
# @option -s --speed=1.0 Set the speed # @option -s --speed=1.0 Set the speed
# @option -f --filename=speech.wav Set the output filename # @option -f --filename=speech.wav Set the output filename
# @arg text! Set the text # @arg text! Set the text
synthesize() { synthesize() {
http_status_code=$(curl -s "${tts_host}/v1/audio/speech" -o "${argc_filename}" -w "%{http_code}" \ http_status_code=$(curl -s "${tts_host}/v1/audio/speech" -o "${argc_filename}" -w "%{http_code}" \
@@ -75,15 +79,15 @@ _choice_lang() {
} }
# @cmd # @cmd
# @option -s --source![`_choice_source`] Set the voice # @option -s --source![`_choice_source`] Set the voice
# @option -f --filename=record.wav Set the output filename # @option -f --filename=record.wav Set the output filename
record() { record() {
parec -d "${argc_source}" --file-format=wav "${argc_filename}" parec -d "${argc_source}" --file-format=wav "${argc_filename}"
} }
# @cmd # @cmd
# @option -l --lang![`_choice_lang`] Set the language # @option -l --lang![`_choice_lang`] Set the language
# @option -f --filename! Set the output filename # @option -f --filename! Set the output filename
transcript() { transcript() {
# Transcribe the specified file # Transcribe the specified file
echo "Transcribing file ${argc_filename}, be patient" echo "Transcribing file ${argc_filename}, be patient"