Skip to content
Advertisement

How to put text and get audio discord.js like google translate?

Is there a way or a module on discord.js that allows you to say vocally some text?

I would need it to make a kind of voice log, a trivial example would be that when someone connects to a voice channel the bot says "$username has entered the voice channel".

Does anyone know how to do this? I would also accept a solution of the web type that I send and it returns a file that I then run, since it does not have to be instantaneous.

Advertisement

Answer

StackOverflow is not really the place to be looking for library/module recommendations. This platform is more to help you solve/understand issues in your existing code, but this question is about finding a library needed to start your coding.

Regardless, I would suggest searching on NPM, or just google, for what you need. There are dozens of modules out there that claim to do exactly what you are looking for. Most of them probably use Google TTS (i.e. the voice google uses in its translator and such). Some of them are built specifically for discord, others aren’t but could be used with discord.

A quick 2-second search led me to find this module: discord-tts.

It claims to be able to do exactly what you’re looking for, and claims to work for both djs v12 and v13. It indeed does use the Google TTS. Do note, however, that Google TTS is pretty limited when it comes to speaking short text. For example, if you give it just one word to say, it probably won’t say anything at all. This issue is probably going to be a common theme across most TTS modules you find.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement