import time @client.command() async def adam(ctx): emoji = '\N{brain}' await ctx.message.add_reaction(emoji) import os import discord from discord.ext import commands from dotenv import load_dotenv from discord import FFmpegPCMAudio from discord.utils import get import youtube_dl import time from apscheduler.schedulers.asyncio import AsyncIOScheduler from apscheduler.triggers.cron import CronTrigger import os import requests import playsound import speech_recognition as sp import speech_recognition as sr from random import randrange from gtts import gTTS import time import subprocess import time subprocess.call("cls", shell=True) adamnome = "ADAM, A . I." print(''' █████╗ ██████╗ █████╗ ███╗ ███╗ ██╔══██╗██╔══██╗██╔══██╗████╗ ████║ ███████║██║ ██║███████║██╔████╔██║ ██╔══██║██║ ██║██╔══██║██║╚██╔╝██║ ██║ ██║██████╔╝██║ ██║██║ ╚═╝ ██║ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ''') voiceChannel = ctx.author.voice.channel await voiceChannel.connect() voice = discord.utils.get(client.voice_clients, guild=ctx.guild) tts =gTTS(text=adamnome,lang='en') filename = "voce.mp3" if os.path.exists(filename): os.remove(filename) tts.save(filename) voice.play(discord.FFmpegPCMAudio("voce.mp3")) time.sleep(2) import time import os saluto = "." sonoio = "." recognizer_instance = sr.Recognizer() with sr.Microphone() as source: recognizer_instance.adjust_for_ambient_noise(source) ascoltami = "sono in ascolto, aspetta un secondo e parla!" voiceChannel = ctx.author.voice.channel voice = discord.utils.get(client.voice_clients, guild=ctx.guild) tts =gTTS(text=ascoltami,lang='it') filename = "voce.mp3" if os.path.exists(filename): os.remove(filename) tts.save(filename) voice.play(discord.FFmpegPCMAudio("voce.mp3")) time.sleep(4) print("sᴏɴᴏ ɪɴ ᴀsᴄᴏʟᴛᴏ... ᴘᴀʀʟᴀ ᴘᴜʀᴇ! ") audio = recognizer_instance.listen(source) text = recognizer_instance.recognize_google(audio, language="it-IT") print("ᴍᴇssᴀɢɢɪᴏ» " + text) #adam try: if text == "chi sei": variabile = sonoio voiceChannel = ctx.author.voice.channel voice = discord.utils.get(client.voice_clients, guild=ctx.guild) tts =gTTS(text=variabile,lang='it') filename = "voce.mp3" if os.path.exists(filename): os.remove(filename) tts.save(filename) voice.play(discord.FFmpegPCMAudio("voce.mp3")) time.sleep(7) await voice.disconnect() if text == "tu sei": variabile = sonoio voiceChannel = ctx.author.voice.channel voice = discord.utils.get(client.voice_clients, guild=ctx.guild) tts =gTTS(text=variabile,lang='it') filename = "voce.mp3" if os.path.exists(filename): os.remove(filename) tts.save(filename) voice.play(discord.FFmpegPCMAudio("voce.mp3")) time.sleep(7) await voice.disconnect() if text == "identificati": voiceChannel = ctx.author.voice.channel voice = discord.utils.get(client.voice_clients, guild=ctx.guild) tts =gTTS(text=variabile,lang='it') filename = "voce.mp3" if os.path.exists(filename): os.remove(filename) tts.save(filename) voice.play(discord.FFmpegPCMAudio("voce.mp3")) time.sleep(7) await voice.disconnect() elif text == "Come stai": variabile = "Bene, grazie. il mio creatore ha sempre cura di me e mi aggiorna costantemente, e tu tutto bene?" voiceChannel = ctx.author.voice.channel voice = discord.utils.get(client.voice_clients, guild=ctx.guild) tts =gTTS(text=variabile,lang='it') filename = "voce.mp3" if os.path.exists(filename): os.remove(filename) tts.save(filename) voice.play(discord.FFmpegPCMAudio("voce.mp3")) time.sleep(5) await voice.disconnect() except Exception as e: variabile = "Contatta il mio creatore, Adam non conosce questo tipo di errore!" except UnknownValueError: variabile = "Contatta il mio creatore, Adam non conosce questo tipo di errore!" except ClientException: await voice.disconnect() await adam(ctx)