-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChatSynthesis.py
34 lines (26 loc) · 1.12 KB
/
ChatSynthesis.py
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
import sys
from application import *
import openai
import os
from util import *
if len(sys.argv) > 1:
if "OPENAI_API_KEY" not in os.environ:
raise Exception("OPENAI_API_KEY environment variable not set")
if "AWS_ACCESS_KEY" not in os.environ:
raise Exception("AWS_ACCESS_KEY environment variable not set")
if "AWS_SECRET_KEY" not in os.environ:
raise Exception("AWS_SECRET_KEY environment variable not set")
if sys.argv[1] == "--delete":
delete_persistent_variable("OPENAI_API_KEY")
delete_persistent_variable("AWS_ACCESS_KEY")
delete_persistent_variable("AWS_SECRET_KEY")
print("All keys removed from system environment variables")
sys.exit(0)
openai.api_key = os.environ["OPENAI_API_KEY"]
prompt = " ".join(sys.argv[1:])
run(prompt) #TODO: this is too much code change it later
else:
set_variable_if_not_exists("OPENAI_API_KEY")
set_variable_if_not_exists("AWS_ACCESS_KEY")
set_variable_if_not_exists("AWS_SECRET_KEY")
print("All keys ready. Use ./ChatSynthesis.py <prompt> to generate text for speech synthesis.")