Discord.py 在不保存音频文件的情况下播放 Gtts

时间:2021-06-24 21:43:03

标签: python discord.py

我有这段代码可以将文本转换为音频并将其保存为 mp3,然后加入语音频道并播放音频文件

@commands.command()
async def tts(self, ctx, *, text):
     sound = gtts(text=text, lang="en", slow=False).save("test.mp3")
     channel=voice_channel.name
     await ctx.send('User is in channel: '+ channel)
     vc = await voice_channel.connect()
     vc.play(discord.FFmpegPCMAudio('test.mp3'), after=print("Done"))

如果不将文本保存为语音并直接从 gtts 播放它,我将如何做到这一点

0 个答案:

没有答案
相关问题