forked from aflorithmic/apiaudio-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
32 lines (24 loc) · 951 Bytes
/
example.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
import aflr
aflr.api_key = "your-key"
# Create a new script and print the script created
script = aflr.Script().create(scriptText="Hello world")
print(script)
# Retrieve the script item and print the script created
script = aflr.Script().retrieve(scriptId=script["scriptId"])
print(script)
# Retrieve all scripts and print the first's script text
scripts = aflr.Script().list()
print(scripts[0]["scriptText"])
# create a text-to-speech
response = aflr.Speech().create(scriptId=script["scriptId"])
print(response)
# get the speech audio files
audio_files = aflr.Speech().retrieve(scriptId=script["scriptId"])
print(audio_files)
# download all speech audio files
# check your folder :) you should have the following audio_files
audio_files = aflr.Speech().download(scriptId=script["scriptId"], destination=".")
print(audio_files)
# Get all available voices and print the first one
all_voices = aflr.Voice().list()
print(all_voices["voices"][0])