Favori dilinizde kopyala-yapıştır hazır örnekler.
const fetch = require('node-fetch');
async function generateSpeech() {
const response = await fetch('https://api.speekoapp.com/tts', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk-speeko_xxx',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'Hello world!',
voice: 'af_heart',
format: 'mp3'
})
});
const data = await response.json();
console.log('Audio URL:', data.url);
console.log('Cost:', data.cost);
}
generateSpeech();const fetch = require('node-fetch');
async function generateVideo() {
const response = await fetch('https://api.speekoapp.com/tts-video', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk-speeko_xxx',
'Content-Type': 'application/json'
},
body: JSON.stringify({
text: 'Check this out!',
voice: 'am_michael',
resolution: '1080p',
aspect_ratio: '16:9',
subtitles: true
})
});
const data = await response.json();
console.log('Video URL:', data.url);
}
generateVideo();const express = require('express');
const app = express();
app.post('/webhook', express.json(), (req, res) => {
const { status, url, job_id, cost } = req.body;
if (status === 'completed') {
console.log('Job completed:', job_id);
console.log('Download at:', url);
console.log('Cost:', cost);
} else if (status === 'failed') {
console.error('Job failed:', job_id);
}
res.status(200).json({ received: true });
});
app.listen(3000, () => {
console.log('Webhook server running...');
});