-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNewsCast.py
47 lines (38 loc) · 1.24 KB
/
NewsCast.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
import apiaudio
apiaudio.api_key = "your-key" # or define env variable: export apiaudio_key=<your-key>
# Write your Script text
text = """
<<soundSegment::intro>>
<<sectionName::intro>>
Welcome to the NewsCast of the day. April 1st 2022.
<<soundSegment::main>>
<<sectionName::main>>
The European Commission and the United States open new chapter in their energy cooperation
State aid: Commission approves €200 million Italian scheme to support the retail trade sector in the context of the coronavirus pandemic
<<soundSegment::outro>>
<<sectionName::outro>>
That's all for today
"""
#Create a script
script = apiaudio.Script.create(scriptText=text, scriptName="news")
sectionProperties = {
'outro': {'endAt': 20, 'justify': 'flex-start'},
}
#Turn your text into speech
r = apiaudio.Speech().create(
scriptId=script.get("scriptId"),
voice="olivia",
speed=105
)
#Master your file and retrieve the URL
template = "headlines"
response = apiaudio.Mastering().create(
scriptId=script.get("scriptId"),
soundTemplate=template,
sectionProperties=sectionProperties,
share=True
)
# Check the response
print('Response from mastering', response)
# Listen and share your audio file
print('Listen to your audio here', response['shareUrl'])