allie
Advanced tools
Sorry, the diff of this file is not supported yet
| Metadata-Version: 1.1 | ||
| Name: allie | ||
| Version: 1.0.5 | ||
| Version: 1.0.6 | ||
| Summary: Biblioteca de inteligência artificial | ||
@@ -5,0 +5,0 @@ Home-page: https://youtube.com/tdcprojetos |
@@ -9,1 +9,2 @@ wikipedia | ||
| google_speech | ||
| pypiwin32 |
@@ -13,2 +13,3 @@ setup.py | ||
| allie/ALLIE_Falas_Offline/ALLIEConexaoOk.mp3 | ||
| allie/ALLIE_Falas_Offline/ALLIEConfigNot.mp3 | ||
| allie/ALLIE_Falas_Offline/ALLIERead.mp3 | ||
@@ -15,0 +16,0 @@ allie/ALLIE_Falas_Offline/ALLIErrorConect.mp3 |
+246
-32
@@ -16,4 +16,6 @@ import wikipedia | ||
| import random | ||
| import pyttsx | ||
| #Criação do objeto da AWS | ||
| engine = pyttsx.init() | ||
| polly = boto3.client('polly') | ||
@@ -27,3 +29,185 @@ ########################## | ||
| base = {} | ||
| confg = {} | ||
| global volume1 | ||
| global voice1 | ||
| global voiceType1 | ||
| global name1 | ||
| volume1 = 0 | ||
| name1 = '' | ||
| voiceType1 = False | ||
| voice1 = 0 | ||
| def activeConfg(): | ||
| global volume1 | ||
| global voice1 | ||
| global voiceType1 | ||
| global name1 | ||
| volume1 = confg['volume'] | ||
| voice1 = confg['voice'] | ||
| voiceType1 = confg['voiceType'] | ||
| name1 = confg['name'] | ||
| #Função de configuração | ||
| def configMenu(): | ||
| global confg | ||
| # inicia o loop para alimentar o arquivo de configurações com uma nova confg | ||
| while True: | ||
| op = input('Operation: ') | ||
| if op == 'config': | ||
| name = input('User Name: ') | ||
| if(name == 'exit'): | ||
| break | ||
| else: | ||
| print('1 for local voice and 2 for online voice') | ||
| voiceType = input('VoiceType: ') | ||
| if (voiceType == 'exit'): | ||
| confg['name'] = name | ||
| confg['ALLIEStatus'] = True | ||
| with open (file_find('config.json', 'confg'), 'w') as ler: | ||
| json.dump(confg,ler) | ||
| break | ||
| else: | ||
| if voiceType == '1': | ||
| confg['voiceType'] = False | ||
| else: | ||
| confg['voiceType'] = True | ||
| print('if voiceType is local report voiceID or voiceType online report voiceName') | ||
| if(voiceType == '1'): | ||
| while True: | ||
| try: | ||
| voice = (input('Voice: ')) | ||
| if (voice == 'exit'): | ||
| confg['name'] = name | ||
| confg['voiceType'] = voiceType | ||
| with open (file_find('config.json', 'confg'), 'w') as ler: | ||
| json.dump(confg,ler) | ||
| break | ||
| voice = int(voice) | ||
| break | ||
| except ValueError: | ||
| print('Previous information does not look like an ID') | ||
| else: | ||
| while True: | ||
| try: | ||
| voice = str(input('Voice: ')) | ||
| if(int(voice) >= 0): | ||
| aux = '' | ||
| aux += 1 | ||
| except TypeError: | ||
| print('Previous information does not look like a VoiceName') | ||
| except ValueError: | ||
| break | ||
| if (voice == 'exit'): | ||
| confg['name'] = name | ||
| confg['voiceType'] = voiceType | ||
| with open (file_find('config.json', 'confg'), 'w') as ler: | ||
| json.dump(confg,ler) | ||
| break | ||
| else: | ||
| volume = input('Volume: ') | ||
| confg['name'] = name | ||
| confg['voice'] = voice | ||
| confg['ALLIEStatus'] = True | ||
| confg['volume'] = int(volume) | ||
| break | ||
| elif op == 'listVoices': | ||
| try: | ||
| if (confg['ALLIEStatus'] == True and confg['voiceType'] == True): | ||
| print(polly.describe_voices()) | ||
| elif (confg['voiceType'] == False): | ||
| voices = engine.getProperty('voices') | ||
| count = 0 | ||
| for voice in voices: | ||
| print(count,voice.name.encode("utf-8")) | ||
| count += 1 | ||
| except UnicodeEncodeError: | ||
| pass | ||
| elif op == 'configVoiceType': | ||
| print('1 for local voice and 2 for online voice') | ||
| aux = input('VoiceType: ') | ||
| if aux == '1': | ||
| confg['voiceType'] = False | ||
| else: | ||
| confg['voiceType'] = True | ||
| print('Success setup') | ||
| break | ||
| elif op == 'configVolume': | ||
| vol = int(input('Volume: ')) | ||
| confg['volume'] = vol | ||
| print('Success setup') | ||
| break | ||
| elif op == 'configVoice': | ||
| print('if voiceType is local report voiceID or voiceType online report voiceName') | ||
| if confg['voiceType'] == False: | ||
| while True: | ||
| try: | ||
| voice = (input('Voice: ')) | ||
| if(voice == 'exit'): | ||
| break | ||
| voice = int(voice) | ||
| break | ||
| except ValueError: | ||
| print('Previous information does not look like an ID') | ||
| else: | ||
| while True: | ||
| try: | ||
| voice = str(input('Voice: ')) | ||
| if(voice == 'exit'): | ||
| break | ||
| if(int(voice) >= 0): | ||
| aux = '' | ||
| aux += 1 | ||
| except TypeError: | ||
| print('Previous information does not look like a VoiceName') | ||
| except ValueError: | ||
| break | ||
| confg['voice'] = voice | ||
| print('Success setup') | ||
| break | ||
| elif op == 'help': | ||
| print('commands:') | ||
| print('config') | ||
| print('configVoiceType') | ||
| print('configVoice') | ||
| print('listVoices') | ||
| print('configVolume') | ||
| print('getConfig') | ||
| print('exit') | ||
| elif op == 'getConfig': | ||
| print('UserName:', confg['name'], '\nVoice:', confg['voice']) | ||
| if confg['voiceType'] == False: | ||
| print('VoiceType: offline') | ||
| else: | ||
| print('VoiceType: online') | ||
| elif op == 'exit': | ||
| break | ||
| else: | ||
| print('The command is not valid') | ||
| with open (file_find('config.json', 'confg'), 'w') as ler: | ||
| json.dump(confg,ler) | ||
| print('Successful all settings have been saved') | ||
| with open (file_find('config.json', 'confg'), 'r') as ler: | ||
| confg = json.load(ler) | ||
| activeConfg() | ||
| #Função responsavel por gerar um token de acesso aleatório | ||
@@ -94,5 +278,3 @@ def GenerateArduinoToken(): | ||
| if(SpeakError == True): | ||
| p = vlc.MediaPlayer(file_find('ALLIEConexaoOk.mp3', 'ALLIE_Falas_Offline')) | ||
| p.audio_set_volume(100) | ||
| p.play() | ||
| player(file_find('ALLIEConexaoOk.mp3', 'ALLIE_Falas_Offline')) | ||
| #Cria uma chave com o nome igual ao token e com o objeto da porta Serial | ||
@@ -105,5 +287,3 @@ Arduinos[token] = LerPort | ||
| if(SpeakError == True): | ||
| p = vlc.MediaPlayer(file_find('ALLIErrorConect.mp3', 'ALLIE_Falas_Offline')) | ||
| p.audio_set_volume(100) | ||
| p.play() | ||
| player(file_find('ALLIErrorConect.mp3', 'ALLIE_Falas_Offline')) | ||
| break | ||
@@ -126,5 +306,3 @@ else: | ||
| if(SpeakError == True): | ||
| p = vlc.MediaPlayer(file_find('ALLIERead.mp3', 'ALLIE_Falas_Offline')) | ||
| p.audio_set_volume(100) | ||
| p.play() | ||
| player(file_find('ALLIERead.mp3', 'ALLIE_Falas_Offline')) | ||
| else: | ||
@@ -215,21 +393,20 @@ return False | ||
| #BETA função que converte palavras em voz multi idiomas usando a AWS ou idiomas nativos da máquina | ||
| def Falar(text,VoiceName = 'Vitoria',volume = 150, online = True, arq = True): | ||
| try: | ||
| _ = requests.get('http://www.google.com/', timeout=5) | ||
| texto = polly.synthesize_speech(Text= text, OutputFormat= 'mp3', VoiceId='Vitoria') | ||
| with open(file_find('ALLIEspeak.mp3', ''), 'wb') as f: | ||
| f.write(texto['AudioStream'].read()) | ||
| f.close() | ||
| p = vlc.MediaPlayer(file_find('ALLIEspeak.mp3', '')) | ||
| p.audio_set_volume(volume) | ||
| p.play() | ||
| except requests.ConnectionError: | ||
| p = vlc.MediaPlayer(file_find('Problema de rede.mp3', 'ALLIE_Falas_Offline')) | ||
| p.audio_set_volume(volume) | ||
| p.play() | ||
| if online != True and arq != True: | ||
| p = vlc.MediaPlayer(arq) | ||
| p.audio_set_volume(volume) | ||
| p.play() | ||
| def Falar(text,volume = 150, online = True, arq = True): | ||
| if(voiceType1 == True): | ||
| try: | ||
| _ = requests.get('http://www.google.com/', timeout=5) | ||
| texto = polly.synthesize_speech(Text= text, OutputFormat= 'mp3', VoiceId = voice1) | ||
| with open(file_find('ALLIEspeak.mp3', ''), 'wb') as f: | ||
| f.write(texto['AudioStream'].read()) | ||
| f.close() | ||
| player(file_find('ALLIEspeak.mp3', '')) | ||
| except requests.ConnectionError: | ||
| player(file_find(file_find('Problema de rede.mp3', 'ALLIE_Falas_Offline'))) | ||
| if online != True and arq != True: | ||
| player(file_find(file_find(arq, 'ALLIE_Falas_Offline'))) | ||
| else: | ||
| engine.setProperty('voice', voice1) | ||
| engine.say(text) | ||
| engine.runAndWait() | ||
@@ -245,3 +422,2 @@ #Esta função grava novas coisa aprendidas por ALLIE com buscas na internet | ||
| Falar(base[Busca]) | ||
| print(base[Busca]) | ||
| else: | ||
@@ -252,2 +428,3 @@ frase = 'Eu verifiquei no meu vocabulário, e não encontrei nada, sobre ' + Busca | ||
| try: | ||
| time.sleep(2) | ||
@@ -257,4 +434,3 @@ _ = requests.get('http://www.google.com/', timeout=5) | ||
| sumario = wikipedia.summary(Busca, sentences=1) | ||
| #print(sumario) | ||
| #Falar(sumario) | ||
| Falar(sumario) | ||
| Gravar_dados(Busca, sumario) | ||
@@ -279,3 +455,2 @@ except wikipedia.exceptions.DisambiguationError as e: | ||
| count += 1 | ||
| print(count) | ||
| if (count == 10): | ||
@@ -303,2 +478,17 @@ for x in range(4): | ||
| def player(file): | ||
| instance = vlc.Instance() | ||
| media = instance.media_new(file) | ||
| player = instance.media_player_new() | ||
| player.set_media(media) | ||
| player.play() | ||
| playing = set([1,2,3,4]) | ||
| time.sleep(0.01) | ||
| while True: | ||
| state = player.get_state() | ||
| if state not in playing: | ||
| break | ||
| if os.path.exists(file_find('base de dados.txt', '')): | ||
@@ -317,5 +507,26 @@ with open (file_find('base de dados.txt', ''), 'r') as ler: | ||
| # verifica se o arquivo de confg exite se sim todas as configurações são lidas | ||
| if os.path.exists(file_find('config.json', 'confg')): | ||
| with open (file_find('config.json', 'confg'), 'r') as ler: | ||
| confg = json.load(ler) | ||
| # se não é então criado um novo arquivo de con cofiguração com as configurções default | ||
| else: | ||
| confg = {'voice': 0, 'volume': 100, 'ALLIEStatus':False, 'name':'', 'voiceType':False} | ||
| player(file_find('ALLIEConfigNot.mp3', 'ALLIE_Falas_Offline')) | ||
| configMenu() | ||
| if(confg['ALLIEStatus'] == False): | ||
| player(file_find('ALLIEConfigNot.mp3', 'ALLIE_Falas_Offline')) | ||
| configMenu() | ||
| estilo = [] | ||
| pesquisa = [] | ||
| activeConfg() | ||
| ouvir = escuta.Recognizer() | ||
@@ -331,3 +542,6 @@ wikipedia.set_lang("Pt") | ||
| #ArduinoRead() | ||
| #configMenu() | ||
| #robot.train(["quem te criou" , "klinsman","quem te fez" , "klinsman","qual é o nome do seu pai" , "klinsman"]) | ||
@@ -334,0 +548,0 @@ ''' |
+1
-1
| Metadata-Version: 1.1 | ||
| Name: allie | ||
| Version: 1.0.5 | ||
| Version: 1.0.6 | ||
| Summary: Biblioteca de inteligência artificial | ||
@@ -5,0 +5,0 @@ Home-page: https://youtube.com/tdcprojetos |
+3
-3
@@ -5,3 +5,3 @@ from setuptools import setup | ||
| setup(name='allie', | ||
| version='1.0.5', | ||
| version='1.0.6', | ||
| description='Biblioteca de inteligência artificial', | ||
@@ -30,3 +30,3 @@ url='https://youtube.com/tdcprojetos', | ||
| install_requires=['wikipedia', 'requests', 'boto3', 'python-vlc', 'chatterbot', | ||
| 'pyserial', 'speechrecognition','google_speech'], | ||
| 'pyserial', 'speechrecognition','google_speech', 'pypiwin32'], | ||
@@ -38,3 +38,3 @@ scripts = [ 'scripts/createFolder.py', 'scripts/configMenu.py'], | ||
| 'allie/ALLIE_Falas_Offline/ALLIERead.mp3', 'allie/ALLIE_Falas_Offline/ALLIErrorConect.mp3', | ||
| 'allie/ALLIE_Falas_Offline/Problema de rede.mp3']), | ||
| 'allie/ALLIE_Falas_Offline/Problema de rede.mp3', 'allie/ALLIE_Falas_Offline/ALLIEConfigNot.mp3']), | ||
| ('Lib/site-packages/allie/ALLIEToken',['allie/ALLIEToken/ArduinoToken.txt']), | ||
@@ -41,0 +41,0 @@ ('Lib/site-packages/allie/conversas',['allie/conversas/I.A dialog.txt','allie/conversas/origens.txt', |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
173666
46.48%22
4.76%533
50.56%