MCPcopy Create free account
hub / github.com/Xchristech2/Zenitsu-Bot / ttsCommand

Function ttsCommand

commands/tts.js:5–28  ·  view source on GitHub ↗
(sock, chatId, text, message, language = 'en')

Source from the content-addressed store, hash-verified

3const path = require('path');
4
5async function ttsCommand(sock, chatId, text, message, language = 'en') {
6 if (!text) {
7 await sock.sendMessage(chatId, { text: 'Please provide the text for TTS conversion.' });
8 return;
9 }
10
11 const fileName = `tts-${Date.now()}.mp3`;
12 const filePath = path.join(__dirname, '..', 'assets', fileName);
13
14 const gtts = new gTTS(text, language);
15 gtts.save(filePath, async function (err) {
16 if (err) {
17 await sock.sendMessage(chatId, { text: 'Error generating TTS audio.' });
18 return;
19 }
20
21 await sock.sendMessage(chatId, {
22 audio: { url: filePath },
23 mimetype: 'audio/mpeg'
24 }, { quoted: message });
25
26 fs.unlinkSync(filePath);
27 });
28}
29
30module.exports = ttsCommand;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected