TTS Dracin

javascript 182 views May 5, 2026
Raw
javascript 68 lines ยท 1,495 chars
import axios from "axios";
import te from "../../src/lib/ourin-error.js";

const pluginConfig = {
  name: "dracin",
  alias: ["dracin-tts", "ttsdracin"],
  category: "tools",
  description: "Text to Speech Dracin AI",
  usage: ".dracin <text>",
  example: ".dracin halo dunia",
  isOwner: false,
  isPremium: false,
  isGroup: false,
  isPrivate: false,
  cooldown: 10,
  energi: 1,
  isEnabled: true,
};

async function dracinTTS(text) {
  const url = `https://api.nexray.eu.cc/ai/dracin-tts?text=${encodeURIComponent(text)}&speed=1.0&volume=0.5&music=false`;

  const res = await axios.get(url, {
    timeout: 120000,
    headers: {
      "user-agent": "Mozilla/5.0",
      accept: "application/json",
    },
  });

  if (!res.data?.status || !res.data?.result) {
    throw new Error("Dracin TTS gagal");
  }

  return res.data.result;
}

async function handler(m, { sock, text }) {
  if (!text) {
    return m.reply(
      `๐ŸŽ™๏ธ *DRACIN TTS*\n\nMasukkan teks yang ingin diubah menjadi suara\n\nContoh:\n\`${m.prefix}dracin halo dunia\``,
    );
  }

  m.react("๐Ÿ••");

  try {
    const audioUrl = await dracinTTS(text);

    m.react("โœ…");

    await sock.sendMedia(
      m.chat,
      audioUrl,
      null,
      m,
      {
        type: "audio",
      },
    );
  } catch (error) {
    console.log(error);
    m.react("โ˜ข");
    m.reply(te(m.prefix, m.command, m.pushName));
  }
}

export { pluginConfig as config, handler };