简体   繁体   中英

How to get rid of this ffmpeg?

I am currently working on a bot. Its function is to join voice channels and speak with tts .

This is my attempt so far:

try {
    const broadcast = client.voice.createBroadcast();
    var channelId = message.member.voice.channelID;
    var channel = client.channels.cache.get(channelId);
    channel.join().then(connection => {
        broadcast.play(discordTTS.getVoiceStream("Staline est né le : 18 Décembre 1878."));
        const dispatcher = connection.play(broadcast);
    });
    message.delete();
}
catch (e) {
    console.log(e);
}

This is the error I'm getting:

events.js: 292
throw er; // Unhandled 'error' event
          ^

    Error: spawn ffmpeg ENOENT
at Process.ChildProcess._handle.onexit(internal / child_process.js: 269: 19)
at onErrorNT(internal / child_process.js: 465: 16)
at processTicksAndRejections(internal / process / task_queues.js: 80: 21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit(internal / child_process.js: 275: 12)
at onErrorNT(internal / child_process.js: 465: 16)
at processTicksAndRejections(internal / process / task_queues.js: 80: 21) {
    errno: -4058,
        code: 'ENOENT',
            syscall: 'spawn ffmpeg',
                path: 'ffmpeg',
                    spawnargs: [
                        '-i', '-',
                        '-analyzeduration', '0',
                        '-loglevel', '0',
                        '-f', 's16le',
                        '-ar', '48000',
                        '-ac', '2',
                        'pipe:1'
                    ]
}

I really don't understand, I never asked for ffmpeg to be here

As far as I know /tts is inner Discord's function (not discord.js). Bot can't join and speak by tts. You can make something like this:

client.on('message', message => {
    message.channel.send(args, {
        tts: true
    });
});

Without joining voice channel!

Update!

I didn't mention that you are using "discord-tts". First of all you have to install all needed dependencies: @discordjs/opus and ffmpeg-static

Then try your code or this:

if (msg.content==="say test 123") {
    const broadcast = bot.voice.createBroadcast();

    if (msg.member.voice.channel) {
        const connection = await msg.member.voice.channel.join();

        broadcast.play(discordTTS.getVoiceStream("test 123"));

        const dispatcher = connection.play(broadcast);

    } else {
        await msg.reply('You need to join a voice channel first!');
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM