Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -64,21 +64,27 @@ api_key = os.getenv("DeepAI_api_key")
|
|
64 |
|
65 |
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
headers=
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
return None
|
83 |
|
84 |
|
|
|
64 |
|
65 |
|
66 |
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
+
def generate_image(emotion_prediction, transcribed_text):
|
71 |
+
try:
|
72 |
+
url = "https://api.deepai.org/api/image-editor"
|
73 |
+
headers = {
|
74 |
+
'api-key': api_key
|
75 |
+
}
|
76 |
+
files = {
|
77 |
+
'image': open('path_to_your_image.jpg', 'rb'), # Replace 'path_to_your_image.jpg' with the actual path to your image file
|
78 |
+
'text': emotion_prediction + " " + transcribed_text
|
79 |
+
}
|
80 |
+
response = requests.post(url, headers=headers, files=files)
|
81 |
+
response_data = response.json()
|
82 |
+
if 'output_url' in response_data:
|
83 |
+
return response_data['output_url']
|
84 |
+
else:
|
85 |
+
return None
|
86 |
+
except Exception as e:
|
87 |
+
print("Error generating image:", e)
|
88 |
return None
|
89 |
|
90 |
|