-
Notifications
You must be signed in to change notification settings - Fork 23
/
main.py
30 lines (23 loc) · 995 Bytes
/
main.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
import asyncio
from util import dreamMachineMake, refreshDreamMachine
async def main():
# Your access_token
access_token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOnsidXNlcl91dWlkIjoiYmVhOTlkMDAtNDc2NS00NDFjLWI0ZjktYjdkMGU1NjIxOTk1IiwiY2xpZW50X2lkIjoiIn0sImV4cCI6MTcxODk3MjEwMH0.vZt6jyHErsa8yuSWRVeYpvlh5xDOZnocI9z36n5QgSA"
prompt = "I flew to the roof"
# The image path can be empty
img_file = ""
# img_file = "img/meinv.png"
make_json = dreamMachineMake(prompt, access_token, img_file)
print(make_json)
task_id = make_json[0]["id"]
while True:
response_json = refreshDreamMachine(access_token)
for it in response_json:
if it["id"] == task_id:
print(f"proceeding state {it['state']}")
if it['video']:
print(f"New video link: {it['video']['url']}")
return
await asyncio.sleep(3)
if __name__ == "__main__":
asyncio.run(main())