forked from aflr-archive/aflr_npm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
35 lines (27 loc) · 929 Bytes
/
example.js
File metadata and controls
35 lines (27 loc) · 929 Bytes
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
const Aflr = require("./lib").default;
require("dotenv").config();
async function example() {
try {
Aflr.configure({ apiKey: process.env.API_KEY, debug: true });
let script = await Aflr.Script.create({ scriptText: "Hello world" });
console.log(script);
script = await Aflr.Script.retrieve(script["scriptId"]);
console.log(script);
let scripts = await Aflr.Script.list();
console.log(scripts);
let voices = await Aflr.Voice.list();
console.log(voices);
let speech = await Aflr.Speech.create({ scriptId: script["scriptId"] });
console.log(speech);
let speechResult = await Aflr.Speech.retrieve(script["scriptId"]);
console.log(speechResult);
let syncSpeechResult = await Aflr.SyncTTS.create({
text: "Instantly converted to text to speech",
voice: "salih"
});
console.log(syncSpeechResult);
} catch (e) {
console.error(e);
}
}
example();