const axios = require('axios'); const cheerio = require('cheerio'); const FormData = require('form-data'); async function ondoku(text, { voice = 'en-US-AdamMultilingualNeural', speed = 1, pitch = 0 } = {}) { try { if (!text) throw new Error('Text is required'); const { data: voices } = await axios.get('https://raw.githubusercontent.com/rynn-k/idk/refs/heads/main/json/ondoku-voice.json'); if (!voices.includes(voice)) throw new Error(`Available voices: ${voices.join(', ')}`); if (speed < 0.3 || speed > 4) throw new Error('Min speed: 0.3, Max speed: 4'); if (pitch < -20 || pitch > 20) throw new Error('Min pitch: -20, Max pitch: 20'); const rynn = await axios.post('https://ondoku3.com/en'); const $ = cheerio.load(rynn.data); const token = $('input[name="csrfmiddlewaretoken"]').attr('value'); const form = new FormData(); form.append('text', text); form.append('voice', voice); form.append('speed', speed.toString()); form.append('pitch', pitch.toString()); const { data } = await axios.post('https://ondoku3.com/en/text_to_speech/', form, { headers: { cookie: rynn.headers['set-cookie'].join('; '), origin: 'https://ondoku3.com', referer: 'https://ondoku3.com/en/', 'x-csrftoken': token, 'x-requested-with': 'XMLHttpRequest', ...form.getHeaders() } }); return data; } catch (error) { throw new Error(error.message); } } // Usage: const resp = await ondoku('hai! apa kabar?', { voice: 'id-ID-ArdiNeural' }); console.log(resp);