Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -96,10 +96,12 @@ from pydub import AudioSegment
|
|
96 |
def function(Textbox, Textbox2, Textbox3, Dropdown):
|
97 |
target = os.environ.get("target")
|
98 |
target2 = os.environ.get("target2")
|
|
|
99 |
os.environ["REPLICATE_API_TOKEN"]
|
100 |
-
|
101 |
-
|
102 |
content = os.environ.get("content")
|
|
|
103 |
link1 = os.environ.get("link1")
|
104 |
path = os.environ.get("path")
|
105 |
link2 = os.environ.get("link2")
|
@@ -172,12 +174,13 @@ def function(Textbox, Textbox2, Textbox3, Dropdown):
|
|
172 |
)
|
173 |
try:
|
174 |
sleep(0.8)
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
|
|
181 |
# reply = reply.replace(" ", "%20")
|
182 |
# image_array = download_image(f"https://api.placid.app/u/pydav4ibo?quote[text]={reply}")
|
183 |
data["messages"].append({"role": "assistant", "content": reply})
|
@@ -205,11 +208,12 @@ def function(Textbox, Textbox2, Textbox3, Dropdown):
|
|
205 |
print(data["messages"])
|
206 |
try:
|
207 |
sleep(0.8)
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
|
|
213 |
# reply = reply.replace(" ", "%20")
|
214 |
# image_array = download_image(f"https://api.placid.app/u/pydav4ibo?quote[text]={reply}")
|
215 |
data["messages"].append({"role": "assistant", "content": reply})
|
@@ -219,7 +223,7 @@ def function(Textbox, Textbox2, Textbox3, Dropdown):
|
|
219 |
"key": "3637c6b5-09c9-4d49-b8fe-a9ffecc36f86",
|
220 |
"voice_id": "male"
|
221 |
}
|
222 |
-
response = requests.post(
|
223 |
output = response.json()
|
224 |
print(output)
|
225 |
output_url = output["output"]["audio"]
|
|
|
96 |
def function(Textbox, Textbox2, Textbox3, Dropdown):
|
97 |
target = os.environ.get("target")
|
98 |
target2 = os.environ.get("target2")
|
99 |
+
target3 = os.environ.get("target3")
|
100 |
os.environ["REPLICATE_API_TOKEN"]
|
101 |
+
openai.api_key = target2
|
102 |
+
openai.api_base = os.environ.get("base")
|
103 |
content = os.environ.get("content")
|
104 |
+
model = os.environ.get("model")
|
105 |
link1 = os.environ.get("link1")
|
106 |
path = os.environ.get("path")
|
107 |
link2 = os.environ.get("link2")
|
|
|
174 |
)
|
175 |
try:
|
176 |
sleep(0.8)
|
177 |
+
chat = openai.ChatCompletion.create(
|
178 |
+
model=model, messages=data["messages"]
|
179 |
+
)
|
180 |
+
reply = chat.choices[0].text
|
181 |
+
# response = requests.post(target2, json=data)
|
182 |
+
# print("target2",target2)
|
183 |
+
# reply = response.content.decode("utf-8")
|
184 |
# reply = reply.replace(" ", "%20")
|
185 |
# image_array = download_image(f"https://api.placid.app/u/pydav4ibo?quote[text]={reply}")
|
186 |
data["messages"].append({"role": "assistant", "content": reply})
|
|
|
208 |
print(data["messages"])
|
209 |
try:
|
210 |
sleep(0.8)
|
211 |
+
chat = openai.ChatCompletion.create(
|
212 |
+
model=model, messages=data["messages"]
|
213 |
+
)
|
214 |
+
reply = chat.choices[0].text
|
215 |
+
# response = requests.post(target2, json=data)
|
216 |
+
# reply = response.content.decode("utf-8")
|
217 |
# reply = reply.replace(" ", "%20")
|
218 |
# image_array = download_image(f"https://api.placid.app/u/pydav4ibo?quote[text]={reply}")
|
219 |
data["messages"].append({"role": "assistant", "content": reply})
|
|
|
223 |
"key": "3637c6b5-09c9-4d49-b8fe-a9ffecc36f86",
|
224 |
"voice_id": "male"
|
225 |
}
|
226 |
+
response = requests.post(target3, headers=headers, json=voice)
|
227 |
output = response.json()
|
228 |
print(output)
|
229 |
output_url = output["output"]["audio"]
|