вот пример nextcord
пишешь botname tts text - текст озвучивается
#############BOT VOICE FROM TEXT#################
@bot.command(name='tts')
async def tts(ctx, *args):
text = " ".join(args)
user = ctx.message.author
if user.voice != None:
try:
vc = await user.voice.channel.connect()
except:
vc = ctx.voice_client
if vc.is_playing():
vc.stop()
if len(text) > 200:
engine.save_to_file(text, 'sound_cash/tts-audio.mp3')
engine.runAndWait()
else:
myobj = gTTS(text=text, lang="ru", slow=False)
myobj.save("sound_cash/tts-audio.mp3")
source = await nextcord.FFmpegOpusAudio.from_probe("sound_cash/tts-audio.mp3", method='fallback')
vc.play(source)
else:
await ctx.send('You need to be in a vc to run this command!')
#############BOT VOICE FROM TEXT#################