-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwelcome.py
35 lines (27 loc) · 987 Bytes
/
welcome.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
import apiaudio
apiaudio.api_key = "your-key" # or define env variable: export apiaudio_key=<your-key>
text = "<<sectionName::welcome>> Hey {{username}}, welcome to my workout app!"
audience = [{"username": "John"}]
# script creation
script = apiaudio.Script().create(
scriptText=text,
projectName="workout_app",
moduleName="welcome",
scriptName="welcome-message",
)
print(f"Script created: \n {script} \n")
# get the scriptId from the script created.
scriptId = script["scriptId"]
# speech creation
response = apiaudio.Speech().create(
scriptId=scriptId, voice="sonia", speed="110", audience=audience
)
print(f"Response from text-to-speech: \n {response} \n")
# master your file
response = apiaudio.Mastering().create(
scriptId=scriptId, soundTemplate="heatwave", audience=audience, share=True
)
# Check the response
print('Response from mastering', response)
# Listen and share your audio file
print('Listen to your audio here', response['shareUrl'])