0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time
import clipboard
import webbrowser
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
import keyboard


Bot = ChatBot('Bot')
trainer = ChatterBotCorpusTrainer(Bot)
trainer.train("chatterbot.corpus.english")

def chat():
    webbrowser.open('https://www.bing.com/translator')
    keyboard_loop = 0
    while keyboard_loop == 29:
        keyboard.send("tab")
        keyboard_loop + 1
    keyboard_loop = 0
    keyboard.send("enter")
    keyboard.send("down")
    keyboard.send("enter")
    keyboard.send("tab")
    while True:
        keyboard_loop = 0
        keyboard.send("tab")
        keyboard.send("enter")
        time.sleep(4000)
        while keyboard_loop == 32:
            keyboard.send("tab")
            keyboard_loop + 1
        keyboard_loop = 0
        keyboard.send("alt"+"a")
        keyboard.send("ctrl"+"c")
        human_input = clipboard.paste()
        bot_input = Bot.get_response(human_input)
        clipboard.copy(bot_input)
        keyboard.send("backscape")
        keyboard.write(bot_input)
        keyboard.send("tab")
        keyboard.send("enter")
        while keyboard_loop == 33:
            keyboard.send("tab")
            keyboard_loop + 1
chat()

I'm making chatbot using translator as audio input/output and chatterbot libary. Problem is when I run it as normal user translator page starts and error "ImportError: You must be root to use this library on linux" shows up in terminal on "keyboard.send("enter")" line, when i installed keyboard lib as root and ran program with "sudo" it's executing only to as I suppose "trainer.train("chatterbot.corpus.english")" line which is strange because without root it's running further. I left this even for about 10-20 minutes and still only chatterbot's dataset seemed loaded.

  • Related: https://stackoverflow.com/questions/48796147/import-error-you-must-be-root – Tyberius Nov 27 '20 at 19:57
  • I found this thread few days ago, besides please read first because I said I installed keyboard as root – KruvskoMPS Nov 27 '20 at 22:34
  • Does the program just hang or throw an error? I would expect training a model to take a long time in general. Have you checked if the training takes a long time when not using root? The import error should happen as soon as the program is run, since it just occurs from loading the library rather than needing to wait until it has entered your chat function. Have you tried to use a debugger to see if the training is actually progressing? – Tyberius Nov 27 '20 at 22:43

0 Answers0