<gh_stars>1-10
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'bobbody.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
import speech_recognition as sr
import pyttsx3
import pywhatkit
import datetime
import wikipedia
import pyjokes

listner = sr.Recognizer()
bob = pyttsx3.init()
#voices = bob.getProperty('voices')
#bob.setProperty('voice',voices[0].id)

class Ui_Frame(object):
    def setupUi(self, Frame):
        Frame.setObjectName("Frame")
        Frame.resize(200, 100)
        Frame.setMinimumSize(QtCore.QSize(200, 100))
        Frame.setMaximumSize(QtCore.QSize(200, 100))
        self.btn_talk = QtWidgets.QPushButton(Frame)
        self.btn_talk.setGeometry(QtCore.QRect(40, 10, 121, 61))
        font = QtGui.QFont()
        font.setPointSize(18)
        self.btn_talk.setFont(font)
        self.btn_talk.setStyleSheet("  border: 2px solid red;\n"
"  border-radius: 25px;\n"
"background:coral")
        self.btn_talk.setObjectName("btn_talk")
        self.label = QtWidgets.QLabel(Frame)
        self.label.setGeometry(QtCore.QRect(60, 80, 141, 16))
        font = QtGui.QFont()
        font.setFamily("Sanskrit Text")
        font.setPointSize(12)
        self.label.setFont(font)
        self.label.setObjectName("label")

        self.retranslateUi(Frame)
        QtCore.QMetaObject.connectSlotsByName(Frame)

        self.btn_talk.clicked.connect(self.run_bob)

    def retranslateUi(self, Frame):
        _translate = QtCore.QCoreApplication.translate
        Frame.setWindowTitle(_translate("Frame", "BOB"))
        self.btn_talk.setText(_translate("Frame", "Talk"))
        self.label.setText(_translate("Frame", "- by <NAME>"))

    def talk(self,text):
        bob.say(text)
        bob.runAndWait()

    def talk_process(self):
        try:
            with sr.Microphone() as source:
                print('listening...')
                voice = listner.listen(source)
                command = listner.recognize_google(voice)
                command = command.lower()
                if 'bob' in command:
                    command = command.replace('bob','')
                    print(command)
        except:
            pass

        return command

    def run_bob(self):

        self.talk("hi, i am bob your personal assistant, how can i help you just tell me i'm listening!")

        command = self.talk_process()

        if 'play' in command:
            song = command.replace('play','')
            self.talk('ok, playing')
            pywhatkit.playonyt(song)

        elif 'time' in command:
            time = datetime.datetime.now().strftime('%I:%M %p')
            print(time)
            self.talk('current time is'+time)

        elif 'search' in command:
            search = command.replace('search','')
            self.talk('ok searching')
            pywhatkit.search(search)
            
        elif 'give me information about' in command:
            wiki = command.replace('give me information about','')
            info = wikipedia.summary(wiki,2)
            print(info)
            self.talk(info)

        #example for whatsappmessage
        #elif "send whatsapp message to" in command:
        #    number = command.replace('send whatsapp message to','')
        #    hour = datetime.datetime.now().strftime('%H')
        #    minute = datetime.datetime.now().strftime('%M')
        #    if 'guru' in number:
        #        msg = number.replace('guru','')
        #        self.talk('ok , message sending')
        #        pywhatkit.sendwhatmsg("add your number here",msg,int(hour)-24+0.015,int(minute))

        elif 'joke' in command:
            joke = pyjokes.get_joke()
            print(joke)
            self.talk(joke)

        elif 'tell me about yourself' in command:
            msg = "i am bob a personal assistant made by <NAME>, i can do so many things like sending whatsapp messages,serching,playing song,i can do anything you want but in verbal way! "
            print(msg)
            self.talk(msg)


        elif 'tell us about our project' in command:
            msg = "this project is called vartalap made by <NAME>. in this project we are try to built artificial itelligent. if you want to add more functionality then you can help us through our github repository! i need your help, make me advance, add function in me so i can give fight google assistant , alexa and siri!"
            print(msg)
            self.talk(msg)           


        else:
            self.talk('sorry, can you please repeat again!')


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Frame = QtWidgets.QFrame()
    ui = Ui_Frame()
    ui.setupUi(Frame)
    Frame.show()
    sys.exit(app.exec_())

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'bobbody.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
import speech_recognition as sr
import pyttsx3
import pywhatkit
import datetime
import wikipedia
import pyjokes

listner = sr.Recognizer()
bob = pyttsx3.init()
#voices = bob.getProperty('voices')
#bob.setProperty('voice',voices[0].id)

class Ui_Frame(object):
    def setupUi(self, Frame):
        Frame.setObjectName("Frame")
        Frame.resize(200, 100)
        Frame.setMinimumSize(QtCore.QSize(200, 100))
        Frame.setMaximumSize(QtCore.QSize(200, 100))
        self.btn_talk = QtWidgets.QPushButton(Frame)
        self.btn_talk.setGeometry(QtCore.QRect(40, 10, 121, 61))
        font = QtGui.QFont()
        font.setPointSize(18)
        self.btn_talk.setFont(font)
        self.btn_talk.setStyleSheet("  border: 2px solid red;\n"
"  border-radius: 25px;\n"
"background:coral")
        self.btn_talk.setObjectName("btn_talk")
        self.label = QtWidgets.QLabel(Frame)
        self.label.setGeometry(QtCore.QRect(60, 80, 141, 16))
        font = QtGui.QFont()
        font.setFamily("Sanskrit Text")
        font.setPointSize(12)
        self.label.setFont(font)
        self.label.setObjectName("label")

        self.retranslateUi(Frame)
        QtCore.QMetaObject.connectSlotsByName(Frame)

        self.btn_talk.clicked.connect(self.run_bob)

    def retranslateUi(self, Frame):
        _translate = QtCore.QCoreApplication.translate
        Frame.setWindowTitle(_translate("Frame", "BOB"))
        self.btn_talk.setText(_translate("Frame", "Talk"))
        self.label.setText(_translate("Frame", "- by <NAME>"))

    def talk(self,text):
        bob.say(text)
        bob.runAndWait()

    def talk_process(self):
        try:
            with sr.Microphone() as source:
                print('listening...')
                voice = listner.listen(source)
                command = listner.recognize_google(voice)
                command = command.lower()
                if 'bob' in command:
                    command = command.replace('bob','')
                    print(command)
        except:
            pass

        return command

    def run_bob(self):

        self.talk("hi, i am bob your personal assistant, how can i help you just tell me i'm listening!")

        command = self.talk_process()

        if 'play' in command:
            song = command.replace('play','')
            self.talk('ok, playing')
            pywhatkit.playonyt(song)

        elif 'time' in command:
            time = datetime.datetime.now().strftime('%I:%M %p')
            print(time)
            self.talk('current time is'+time)

        elif 'search' in command:
            search = command.replace('search','')
            self.talk('ok searching')
            pywhatkit.search(search)
            
        elif 'give me information about' in command:
            wiki = command.replace('give me information about','')
            info = wikipedia.summary(wiki,2)
            print(info)
            self.talk(info)

        #example for whatsappmessage
        #elif "send whatsapp message to" in command:
        #    number = command.replace('send whatsapp message to','')
        #    hour = datetime.datetime.now().strftime('%H')
        #    minute = datetime.datetime.now().strftime('%M')
        #    if 'guru' in number:
        #        msg = number.replace('guru','')
        #        self.talk('ok , message sending')
        #        pywhatkit.sendwhatmsg("add your number here",msg,int(hour)-24+0.015,int(minute))

        elif 'joke' in command:
            joke = pyjokes.get_joke()
            print(joke)
            self.talk(joke)

        elif 'tell me about yourself' in command:
            msg = "i am bob a personal assistant made by <NAME>, i can do so many things like sending whatsapp messages,serching,playing song,i can do anything you want but in verbal way! "
            print(msg)
            self.talk(msg)


        elif 'tell us about our project' in command:
            msg = "this project is called vartalap made by <NAME>. in this project we are try to built artificial itelligent. if you want to add more functionality then you can help us through our github repository! i need your help, make me advance, add function in me so i can give fight google assistant , alexa and siri!"
            print(msg)
            self.talk(msg)           


        else:
            self.talk('sorry, can you please repeat again!')


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Frame = QtWidgets.QFrame()
    ui = Ui_Frame()
    ui.setupUi(Frame)
    Frame.show()
    sys.exit(app.exec_())
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'bobbody.ui' # # Created by: PyQt5 UI code generator 5.15.1 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again.  Do not edit this file unless you know what you are doing. #voices = bob.getProperty('voices') #bob.setProperty('voice',voices[0].id) #example for whatsappmessage #elif "send whatsapp message to" in command: #    number = command.replace('send whatsapp message to','') #    hour = datetime.datetime.now().strftime('%H') #    minute = datetime.datetime.now().strftime('%M') #    if 'guru' in number: #        msg = number.replace('guru','') #        self.talk('ok , message sending') #        pywhatkit.sendwhatmsg("add your number here",msg,int(hour)-24+0.015,int(minute))