TBL Codes
📌 TTS Generator TBH Code 📌
This code is tested & working perfectly ✅
📜 Description:
Advanced Text-to-Speech generator that converts text into natural speech audio and supports 10 languages with high-quality voice output also to view more languages & voice accents click here
🚀 Command: /tts
⏳ Wait for answer: ❌ Off
🛠 TBH Code:
let textToConvert = "";
let languageToUse = "en";
if (params) {
let parts = params.trim().split(" ");
let supportedLanguages = ['en','hi','ur','ta','es','fr','de','it','ru','ja'];
let lastPart = parts[parts.length - 1].toLowerCase();
if (parts.length >= 2 && supportedLanguages.includes(lastPart)) {
textToConvert = parts.slice(0, -1).join(" ");
languageToUse = lastPart;
} else {
textToConvert = params;
}
} else {
Api.sendMessage({
chat_id: chat.id,
text: "❌ Please provide text to convert!\n\n<b>Usage:</b>\n• /tts <code>{text} {langcode}</code>\n• /tts <code>{text}</code>\n\n<b>Example:</b>\n• <code>/tts hello</code>\n• <code>/tts hello en</code>",
parse_mode: "HTML",
reply_to_message_id: msg.message_id
});
return;
}
if (!textToConvert.trim()) {
Api.sendMessage({
chat_id: chat.id,
text: "❌ No text found to convert!",
parse_mode: "HTML",
reply_to_message_id: msg.message_id
});
return;
}
if (textToConvert.length > 500) {
Api.sendMessage({
chat_id: chat.id,
text: "❌ Text too long. Maximum 500 characters allowed.",
parse_mode: "HTML",
reply_to_message_id: msg.message_id
});
return;}
let statusMsg = await Api.sendMessage({
chat_id: chat.id,
text: "🔄 Processing your TTS request... This may take a few seconds",
parse_mode: "HTML",
reply_to_message_id: msg.message_id});
try {
Api.sendChatAction({
chat_id: chat.id,
action: "upload_audio"
});
let response = await HTTP.post({
url: "https://flashcomapi.alwaysdata.net/api/tts-free",
body: {
text: textToConvert.trim(),
language: languageToUse,
telegram_id: user.id.toString(),
provider: "gs" //You can change to 'vi' read more: https://telegra.ph/Free-TTS-API---Voice-Models-Documentation-11-05
},
headers:
10 · 934 ·