Skip to content

Commit

Permalink
Merge pull request #202 from dheavy/feat/tts-openai-gracefull-error-s…
Browse files Browse the repository at this point in the history
…hutdown

Shutdown gracefully if OpenAI key missing for default TTS
  • Loading branch information
tyfiero authored Apr 1, 2024
2 parents fd177d6 + fe1330a commit 30774b3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions software/source/server/services/tts/openai/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
import subprocess
import tempfile

from source.server.utils.logs import logger
from source.server.utils.logs import setup_logging
setup_logging()

# If this TTS service is used, the OPENAI_API_KEY environment variable must be set
if not os.getenv('OPENAI_API_KEY'):
logger.error("")
logger.error(f"OpenAI API key not found. Please set the OPENAI_API_KEY environment variable, or run 01 with the --local option.")
logger.error("Aborting...")
logger.error("")
os._exit(1)

client = OpenAI()

class Tts:
Expand Down

0 comments on commit 30774b3

Please sign in to comment.