-
Notifications
You must be signed in to change notification settings - Fork 0
/
campaign.py
168 lines (162 loc) · 6.46 KB
/
campaign.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import os
import requests
from dotenv import load_dotenv
load_dotenv()
bearer_token = os.getenv('REPHRASE_API_KEY')
url = "https://personalized-brand.api.rephrase.ai/v2/campaign/create"
with open('summary.txt') as f:
summary = f.read()
payload = {
"videoDimension": {"height": 1080, "width": 1920},
"scenes": [
{
"elements": [
{
"style": {
"height": "100%",
"width": "100%",
"position": "absolute",
"zIndex": 1,
},
"asset": {
"kind": "Image",
"use": "Background",
"url": "https://www.musicinminnesota.com/wp-content/uploads/2021/02/Michael-Jackson-live.jpg",
},
},
{
"style": {
"position": "absolute",
"zIndex": 2,
"bottom": "0em",
"objectFit": "cover",
"height": "37.5em",
"width": "66.66666666666667em",
"left": "16.666666666666664em",
},
"asset": {
"kind": "Spokesperson",
"spokespersonVideo": {
"output_params": {
"video": {
"resolution": {"height": 720, "width": 1280},
"background": {"alpha": 0},
"crop": {"preset": "MS"},
}
},
"model": "danielle_pettee_look_2_nt_aug_2022",
"voiceId": "7bc739a4-7abc-46db-bc75-e24b6f899fa9__005",
"gender": "female",
"transcript": "<speak>"+summary+"</speak>",
"transcript_type": "ssml_limited",
},
},
},
]
},
{
"elements": [
{
"style": {
"height": "100%",
"width": "100%",
"position": "absolute",
"zIndex": 1,
},
"asset": {
"kind": "Image",
"use": "Background",
"url": "https://i.hurimg.com/i/hdn/75/0x0/63807b4d4e3fe0216cfc0529.jpg",
},
},
{
"style": {
"position": "absolute",
"zIndex": 2,
"bottom": "0em",
"objectFit": "cover",
"height": "37.5em",
"width": "66.66666666666667em",
"left": "16.666666666666664em",
},
"asset": {
"spokespersonVideo": {
"output_params": {
"video": {
"resolution": {"height": 720, "width": 1280},
"background": {"alpha": 0},
"crop": {"preset": "MS"},
}
},
"model": "danielle_pettee_look_2_nt_aug_2022",
"voiceId": "7bc739a4-7abc-46db-bc75-e24b6f899fa9__005",
"gender": "female",
"transcript": "<speak>In 1982, Michael released, Thriller, which spent months at the top of the Billboard 200 charts... Cause this is thriller, thriller night... </speak>",
"transcript_type": "ssml_limited",
},
"kind": "Spokesperson",
},
},
]
},
{
"elements": [
{
"style": {
"height": "100%",
"width": "100%",
"position": "absolute",
"zIndex": 1,
},
"asset": {
"kind": "Image",
"use": "Background",
"url": "https://blog.siriusxm.com/wp-content/uploads/2022/11/MichaelJacksonChannel-1117.jpg",
},
},
{
"style": {
"position": "absolute",
"zIndex": 2,
"bottom": "0em",
"objectFit": "cover",
"height": "37.5em",
"width": "66.66666666666667em",
"left": "16.666666666666664em",
},
"asset": {
"spokespersonVideo": {
"output_params": {
"video": {
"resolution": {"height": 720, "width": 1280},
"background": {"alpha": 0},
"crop": {"preset": "MS"},
}
},
"model": "danielle_pettee_look_2_nt_aug_2022",
"voiceId": "7bc739a4-7abc-46db-bc75-e24b6f899fa9__005",
"gender": "female",
"transcript": "<speak>Check out Michael's wikipedia to know more about him. Thank you, have a great day.</speak>",
"transcript_type": "ssml_limited",
},
"kind": "Spokesperson",
},
},
]
},
],
"title": "Into to MJ",
"thumbnailUrl": "https://blog.siriusxm.com/wp-content/uploads/2022/11/MichaelJacksonChannel-1117.jpg",
}
headers = {
"accept": "application/json",
"Authorization": bearer_token,
"content-type": "application/json",
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
campaign_id = data['campaign_id']
print(campaign_id)
f = open(".env", "a")
f.write("CAMPAIGN_ID="+campaign_id)
f.close()