This repository has been archived by the owner on Jan 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
birdcache_v3.py
70 lines (57 loc) · 1.78 KB
/
birdcache_v3.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
from pprint import pprint
import json
import requests
API_KEY = "YOUR_API_KEY_HERE"
VOICE_NAME = "linda"
ENDPOINT_URL = "https://v1.api.audio/birdcache"
the_sentence = "Hi {{username|friend}}, welcome to {{city|tallinn}}. It is {{weather|rainy}} today. Have a great {{day|day}}"
audience = {
"username": ["linda", "anne", "salih", "matt"],
"city": ["istanbul", "tallinn", "london", "barcelona"],
"weather": ["rainy", "sunny", "cloudy", "windy"],
"day": ["monday", "friday", "sunday"],
}
mastering_sound_template = "openup"
def birdcache_v3_speech():
r = requests.post(
url=ENDPOINT_URL,
headers={"x-api-key": API_KEY},
data=json.dumps(
{
"voice": VOICE_NAME,
"type": "speech",
"text": the_sentence,
"audience": audience,
}
),
)
r = r.json()
pprint("speech text files produced:")
for req in r:
print(req["text"])
pprint("speech urls produced:")
for req in r:
print(req["text"] + " - " + (req["url"] if req["ready"] else "in progress"))
def birdcache_v3_mastering():
r = requests.post(
url=ENDPOINT_URL,
headers={"x-api-key": API_KEY},
data=json.dumps(
{
"voice": VOICE_NAME,
"type": "mastering",
"text": the_sentence,
"audience": audience,
"soundTemplate": mastering_sound_template,
}
),
)
r = r.json()
pprint("mastering text files produced:")
for req in r:
print(req["text"])
pprint("mastering urls produced:")
for req in r:
print(req["text"] + " - " + (req["url"] if req["ready"] else "in progress"))
birdcache_v3_speech()
birdcache_v3_mastering()