提问者:小点点

可以为不和谐音乐机器人编程自动语音吗?


所以,这个标题基本上以简短的形式解释了我对我的不和谐机器人的问题。更具体地说,如果一首音乐曲目排在第一位,并且它没有遵循公会配置的指导方针,例如它包含亵渎,音频有一个被批准的版权侵权投诉,由原始发布者通过机器人的网站提交给我们,禁止收听音频,或者它是一个尖叫者,它会自动说一条如下信息:

计划此时播放的当前音乐音量过大或超过音高频率限制。跳到队列中的下一个音乐。

当前定时播放的音乐已被标记为含有亵渎语言,不符合公会配置的指引。正在跳到队列中的下一个音乐。

当前计划在此时播放的音乐有版权侵权投诉,表明原始发布者限制收听音频。跳到队列中的下一个音乐。

是否有可能为不和谐机器人编程和自动语音?

提前感谢。


共1个答案

匿名用户

我会帮你实现用户Amadan的想法到discord.py,首先你需要安装google text to语音python api:

pip install gtts

这个答案将假设您没有使用discord.py的重写分支。

import os
import discord
from gtts import gTTS

if not discord.opus.is_loaded():
    # or libopus.so on linux in the current directory
    # you should replace this with the location the
    # opus library is located in and with the proper filename.
    discord.opus.load_opus('opus')

if not os.path.exists('message1.mp3'):

    tts = gTTS("The current music scheduled to play at this time is too intense in volume or exceeds "
               "the frequency limits for pitch. Skipping to next music in queue.")
    with open('message1.mp3', 'wb') as f:
        tts.write_to_fp(f)

if not os.path.exists('message2.mp3'):
    tts = gTTS("The current music scheduled to play at this time has been marked for containing profane"
               " language and does not comply with the guild-configured guidelines. "
               "Skipping to next music in queue.")
    with open('message2.mp3', 'wb') as f:
        tts.write_to_fp(f)

if not os.path.exists('message3.mp3'):
    tts = gTTS("The current music scheduled to play at this time has a copyright infringement complaint "
               "which indicates that the original publisher restricts listening to the audio. "
               "Skipping to next music in queue.")
    with open('message3.mp3', 'wb') as f:
        tts.write_to_fp(f)

@bot.command(pass_context=True)
async def play(ctx, num):
    vc = ctx.author.voice.voice_channel

    voice = await bot.join_voice_channel(vc)

    player = voice.create_ffmpeg_player('message{}.mp3'.format(num))
    player.start()

现在不和谐,当您在语音频道并输入