Exemplo n.º 1
0
def menu():
    op0 = '\033[4m\033[1m' + Back.LIGHTYELLOW_EX + 'TABLE OF CONTENTS' + Back.LIGHTYELLOW_EX
    op1 = '1. English -> Morse'
    op2 = '2. Morse -> English'
    op3 = '3. See Morse Code'
    op4 = '4. Instructions (for converting Morse to English)'
    op5 = '5. Exit'

    print(Back.LIGHTYELLOW_EX + '                                ' +
          Back.LIGHTYELLOW_EX + '\033[4m\033[1mTABLE OF CONTENTS' +
          Back.LIGHTYELLOW_EX + '                               ' + '\033[0m')

    #print(Back.LIGHTYELLOW_EX + '\033[1m' + op0.ljust(70, ' ') + '\033[0m')
    print(Back.LIGHTYELLOW_EX + '\033[1m' + op1.ljust(80, ' ') + '\033[0m')
    print(Back.LIGHTYELLOW_EX + '\033[1m' + op2.ljust(80, ' ') + '\033[0m')
    print(Back.LIGHTYELLOW_EX + '\033[1m' + op3.ljust(80, ' ') + '\033[0m')
    print(Back.LIGHTYELLOW_EX + '\033[1m' + op4.ljust(80, ' ') + '\033[0m')
    print(Back.LIGHTYELLOW_EX + Fore.BLUE + '\033[1m' + op5.ljust(80, ' ') +
          '\033[0m')
    print(Style.RESET_ALL, end='')
    time.sleep(0.4)
    print(Fore.GREEN + Style.BRIGHT + '\rEnter your choice:' + Style.RESET_ALL,
          end='')
    utter.say('Enter your choice from above table of contents')
    time.sleep(3)
Exemplo n.º 2
0
def main():
    hour = time.localtime().tm_hour
    preferences = get_preferences()
    title = preferences.get_user_title()  # mam? sir?
    print_cmds = preferences.get_print_cmds_on_start()

    if hour < 12:
        greeting = "Good morning {},".format(title)
    else:
        greeting = "Good evening {},".format(title)

    winspeech.say(greeting + " what can I do for you?")
    speechutils.initialize()
    print("Freya is ready to take commands!")

    if print_cmds:
        print("Available commands:\n")
        phrase_dict = get_phrases()
        phrases = []

        for phrase_list in phrase_dict.values():
            phrases.extend(phrase_list)

        phrases.sort()

        for phrase in phrases:
            print("\t" + phrase)

        print()

    while winspeech.is_listening():
        pass
Exemplo n.º 3
0
def speechRecog(result, listener):
    print("You Said: ", result)

    winspeech.say(result)
    if (result == "stop"):
        winspeech.stop_listening()
        sys.exit(0)
Exemplo n.º 4
0
def OpenApplication(applicationDisplayName,allApplicationList):
    try:
        os.startfile(allApplicationList[applicationDisplayName])
        print("Okay, Opening "+applicationDisplayName)
        winspeech.say("Okay, Opening "+applicationDisplayName)
    except:
        print("Could not find the application you are asking for.")
        winspeech.say("Could not find the application you are asking for.")
Exemplo n.º 5
0
def speech(letter):
    if letter == ' ':
        letter = 'Space'
    else:
        letter = letter.upper()

    utter.say(letter)
    time.sleep(1.3)
Exemplo n.º 6
0
def op_speech(in_give, in_want):
    for_value = [str(in_want).strip()]
    listener = winspeech.listen_for(for_value, callback)
    winspeech.say(str(in_give))
    time.sleep(5)
    listener.stop_listening()
    global phrase
    return phrase
Exemplo n.º 7
0
def talk(t):
 for i in  range(t):
  r = sr.Recognizer()
  with sr.Microphone() as source:
    print("Say something!")
    audio = r.listen(source)
    y = r.recognize_google(audio) 
  response = bot.get_response(y)
  winspeech.say (response)
Exemplo n.º 8
0
 def sayExecute(self, stock={}):
     if os.name == 'posix':  # only in win speech operation
         os.system('say %s %s' %
                   (stock.get('operation'), stock.get('quantity')))
     else:
         import winspeech
         winspeech.say('order %s %s %s' %
                       (stock.get('quantity'), stock.get('operation'),
                        stock.get('stop_loss')[2:]))
Exemplo n.º 9
0
def  translate(lang):
 text = input("what do you want to translate ")
 blob = TextBlob(text)
 if lang == 'en':
  winspeech.say(text)
 abc = blob.translate(to=lang)
 winspeech.say(abc)
 print (abc)
 return (abc)
Exemplo n.º 10
0
def Wikipedia(Word):
    try:
        winspeech.say("loading the summary for you")
        #print("In Wikipedia function")
        page = wikipedia.page(Word)
        #wikipedia.exceptions.DisambiguationError
        summary_text = page.summary
        ##  print(page.images)
        return summary_text
    except:
        print("Network error try again! ")
Exemplo n.º 11
0
def CreateMail(text, subject, recipientNameInput):
    outlook = win32.Dispatch('outlook.application')
    mail = outlook.CreateItem(0)
    mail.To = GetNameEmailMap()[recipientNameInput]
    winspeech.say("Please provide the subject line")
    mail.Subject = input("Please provide the subject line : ")
    winspeech.say(
        "Please provide body of the mail, Please say Buddy Stop in an interval to stop dictating"
    )
    mail.HtmlBody = input("Please provide body of the mail : ")
    mail.Display(True)
    return
Exemplo n.º 12
0
def Exit():
    Headings(5)
    print(Fore.BLUE + Style.BRIGHT + '\n\n\nHave a nice day ?')
    print(Fore.BLUE + Style.BRIGHT + 'Happy Learning!\n\n\n\n\n\n\n\n')
    print(Fore.RED + '\033[4m', end='')
    print(''.ljust(80, ' '))
    print(Style.RESET_ALL)
    print(Fore.LIGHTRED_EX + 'Systems are terminating...' + Style.RESET_ALL)
    utter.stop_talking()
    utter.say('Have a nice Day, Happy Learning!')
    time.sleep(3.5)
    exit()
Exemplo n.º 13
0
def Loading():
    print('\rLoading', end='')
    time.sleep(0.7)
    utter.say('Welcome to Morse Code Program')

    print('\rLoading.', end='')
    time.sleep(1)
    print('\rLoading..', end='')
    time.sleep(1)
    print('\rLoading...', end='')
    time.sleep(2)
    print('\r', end='')
Exemplo n.º 14
0
def findIntent(headers,params):
    try:
        r = requests.get('https://westus.api.cognitive.microsoft.com/luis/v2.0/apps/7c51f1a4-4c38-4c6a-8929-337c6e5c7e6f',headers=headers, params=params)
        result = r.json()
        print(result)
        topScoringIntent = result['topScoringIntent']['intent']
        
        if topScoringIntent == "openApplication":
            entities = result['entities']
            if len(entities) > 0:
                entity = entities[0]["entity"].lower()
                allApplicationList = CreateFileMaps()
                OpenApplication(entity,allApplicationList)
                
            else:
                print("Can't understand the application name, or it might not be present")
                winspeech.say("Can't understand the application name, or it might not be present")

    except Exception as e:
        print("[Errno {0}] {1}".format(e.errno, e.strerror))
Exemplo n.º 15
0
def respond(phrase,
            prepend_positive_response=False,
            override_subtitle=False,
            say_wait=False):
    """
    Call this method to make Freya respond
    Parameters:
            phrase: The phrase to say.
            prepend_positive_response: A boolean denoting whether or not to prepend a positive response to the phrase. False by default.
            override_subtitle: If true the subtitle will be printed not matter what the preference is set to. Use it wisely.
            say_wait: Will use the customized winspeech module's say_wait() method instead of say()
    """
    if prepend_positive_response:
        phrase = _get_positive_response() + " " + phrase
    phrase = phrase.lower().capitalize()  # Fix stuff
    if preferences.get_print_subtitle():
        print("Freya: " + phrase + "\n")
    if say_wait:
        winspeech.say_wait(phrase)
        return
    winspeech.say(phrase)
Exemplo n.º 16
0
def CreateEmail(output):
    try:
        entities = output['entities']
        #print(len(entities))
        if len(entities) > 0:
            print("Entitites")
        else:
            print("Please provide the recipient email")
            winspeech.say_wait("Please provide the recipient email")
            userInputMailId = GSTT.getSpeechToText()
            recipient = OCH.CheckEmailMatch(userInputMailId)
            print(recipient)
            print("Please prove the Subject of the email")
            winspeech.say_wait("Please provide the Subject of the email")
            userEmailSubject = GSTT.getSpeechToText()
            print("Okay, opening new email")
            winspeech.say("Please wait while opening new email")
            OCH.CreateEmail(recipient["email"],userEmailSubject)
            
    
    except Exception as e:
        print("Error in show create mail "+str(e))
Exemplo n.º 17
0
    def OnEnter(self, event):

        input = self.txt.GetValue()
        input = input.lower()
        winspeech.say(input)
        try:
            res = client.query(input)
            answer = next(res.results).text
            print answer
            winspeech.say(answer)

        except:
            try:
                input = input.split(' ')
                input = ' '.join(input[2:])
                print wikipedia.summary(input)
                qu = wikipedia.summary(input)
                winspeech.say(qu)
            except:

                print "Sorry, please try a different "
                winspeech.say("Try another question")
Exemplo n.º 18
0
def Headings(option_choosed):
    if option_choosed == 1:
        no1 = '. .. ... E N G L I G H   to   M O R S E ... .. .'
        print(Style.BRIGHT + Fore.MAGENTA + '\033[4m' + ' ' * 80 +
              Style.RESET_ALL)
        print(Style.BRIGHT + Fore.MAGENTA + '\033[4m', end='')
        utter.stop_talking()
        utter.say('English to Morse')
        print('1) ', end='')
        print(no1.center(77, ' '))
        print(Style.RESET_ALL, end='')
        time.sleep(1.4)
        return
    elif option_choosed == 2:
        no2 = '. .. ... M O R S E   to   E N G L I S H ... .. .'
        print(Style.BRIGHT + Fore.MAGENTA + '\033[4m' + ' ' * 80 +
              Style.RESET_ALL)
        print(Style.BRIGHT + Fore.MAGENTA + '\033[4m', end='')
        utter.stop_talking()
        utter.say('Morse to english')
        print('2) ', end='')
        print(no2.center(77, ' '))
        print(Style.RESET_ALL, end='')
        time.sleep(1.4)
        return
    elif option_choosed == 4:
        no4 = '. .. ... I N S T R U C T I O N S ... .. .'
        print(Style.BRIGHT + Fore.MAGENTA + '\033[4m' + ' ' * 80 +
              Style.RESET_ALL)
        print(Style.BRIGHT + Fore.MAGENTA, end='')
        utter.stop_talking()
        utter.say('Instructions')
        print('\033[4m' + '4) ', end='')
        print(no4.center(77, ' '))
        print(Style.RESET_ALL, end='')
        time.sleep(1.4)
        return
    elif option_choosed == 5:
        no5 = '. .. ... EXIT ... .. .'
        print(Style.BRIGHT + Fore.RED + '\033[4m' + ' ' * 80 + Style.RESET_ALL)
        print(Style.BRIGHT + Fore.RED, end='')
        print('\033[4m' + '5) ', end='')
        print(no5.center(77, ' '))
        print(Style.RESET_ALL, end='')
Exemplo n.º 19
0
 def say_message(self):
     winspeech.say(self.target_time)
     winspeech.say("予定は" + self.message + "です。場所は" + self.basho + "です")
Exemplo n.º 20
0
def log(text):
    print('INFO: {0}: {1}'.format(
        datetime.now().strftime('[%d.%m.%Y, %H:%M:%S]'), text))
    winspeech.say(text)
Exemplo n.º 21
0
def warning(text):
    print('WARNING: {0}: {1}'.format(
        datetime.now().strftime('[%d.%m.%Y, %H:%M:%S]'), text))
    winspeech.say("Uwaga! {}".format(text))
Exemplo n.º 22
0
def error(text):
    print('ERROR: {0}: {1}'.format(
        datetime.now().strftime('[%d.%m.%Y, %H:%M:%S]'), text))
    winspeech.say("Wystąpił błąd. {}".format(text))
Exemplo n.º 23
0
#creating chat bot
bot = ChatBot('test')

#reading from file
conv = open('M.txt').readlines()

#bot training
bot.set_trainer(ListTrainer)

#trained for conversation
bot.train(conv)

#recognizing audio

while True:

    request = input('You: ')

    response = bot.get_response(request)
    winspeech.say(response)

    #response of the bot
    print('Bot: ', response)

if result == 'Bye':
    winspeech.stop_listening()
    sys.exit(0)

#conversaation ends
Exemplo n.º 24
0
import winspeech
text = "Hello"
#winspeech.say("99 bottles of beer on the wall")

count = 99
while count > 0:

    phrase1 = count, "bottles of beer on the wall,", count, "bottles of beer, you take one down, you pass it around,"
    count -= 1
    print(phrase1)
    winspeech.say(phrase1)
    phrase2 = count, "bottles of beer on the wall, bottles of beer... "
    print(phrase2)
    winspeech.say(phrase2)
Exemplo n.º 25
0
def talk(audio):
    winspeech.say(audio)
Exemplo n.º 26
0
def voiceOutput(text):
    winspeech.say(text)
    time.sleep(len(text) / 15)
Exemplo n.º 27
0
def TwitterAnalysis(topic, tweetCount):
    winspeech.say("Analyzing the tweet sentiments for you!")
    sa = SentimentAnalysis()
    repo = sa.DownloadData(topic, tweetCount)
    reportText = "here is the report for you sir!"
    return repo
Exemplo n.º 28
0

#if __name__== "__main__":

birthdays = {
    'arshdeep': ' 3 May',
    'harman': '22 Mar',
    'rashpal': '21 apr',
    'daljit ': '27 dec'
}
winspeech.initialize_recognizer(winspeech.INPROC_RECOGNIZER)
os.startfile('HARMAN GUI FINAL_3.0.rmskin')
time.sleep(1)
pyautogui.press('enter')
pyautogui.hotkey('winleft', 'd')
winspeech.say(
    "Hello! my name is Harman your personal assistant, How may I help you ?")
time.sleep(5)
#localtime = time.asctime( time.localtime(time.time()) )
#todaydate =  localtime[8:10]+" "+localtime[4:7]
#print(todaydate)
#if todaydate in list(birthdays.values()):
#print(birthdays.(todaydate))

while 1:

    text, tags = takeVoiceInput()
    print(text)
    print(tags)

    for t in tags:
        if t == "open":
Exemplo n.º 29
0
def talk(text_to_audio):
    winspeech.say(text_to_audio)
Exemplo n.º 30
0
def CaptureFaceAndStartRecognize():

    personGroupId = FRC.personGroupId
    cascPath = 'CognitiveFace/haarcascade_frontalface_default.xml'
    faceCascade = cv2.CascadeClassifier(cascPath)

    video_capture = cv2.VideoCapture(0)

    faceCounter = 0
    faceCounterThreshhold = 20

    FaceResultMessage = "Please hold still and look at the camera!"
    messageTextColor = (255, 255, 255)
    #userName = ""

    while True:
        # Capture frame-by-frame
        ret, frame = video_capture.read()
        k = cv2.waitKey(1)

        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

        faces = faceCascade.detectMultiScale(
            gray,
            scaleFactor=1.1,
            minNeighbors=5,
            minSize=(30, 30),
            #flags=cv2.CV_HAAR_SCALE_IMAGE
        )

        # Draw a rectangle around the faces
        for (x, y, w, h) in faces:
            #print(faceCounter)
            if faceCounter == faceCounterThreshhold:
                img_name = r"currentImage.png"
                cv2.imwrite(img_name, frame)
                print("{} written!".format(img_name))

                global userName
                userName = MFR.DetectFaceMyImage(personGroupId, img_name)
                if userName != None:
                    #print(userName)
                    video_capture.release()
                    cv2.destroyAllWindows()
                    return userName
                else:
                    faceCounter = 0
                    FaceResultMessage = "Authentication Failed ! Trying Again."
                    winspeech.say("Authentication Failed.")
                    messageTextColor = (0, 0, 255)
            elif faceCounter > (faceCounterThreshhold - 5):
                cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
                cv2.putText(frame, "Please wait! Authenticating you.",
                            (x - 10, y - 10), cv2.FONT_HERSHEY_PLAIN, 1,
                            (0, 255, 255))
            else:
                cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
                cv2.putText(frame, FaceResultMessage, (x - 10, y - 10),
                            cv2.FONT_HERSHEY_PLAIN, 1, messageTextColor)
            faceCounter = faceCounter + 1
        # Display the resulting frame
        cv2.imshow('Video', frame)

        if k % 256 == 27:
            # ESC pressed
            print("Escape hit, closing...")
            break
        elif k % 256 == 32:
            img_name = "currentImage.png"
            cv2.imwrite(img_name, frame)
            print("{} written!".format(img_name))

        #time.sleep(1)

    # When everything is done, release the capture
    video_capture.release()
    cv2.destroyAllWindows()


# authenticationOutput = CaptureFaceAndStartRecognize()

# if authenticationOutput == None:
#     sayString = f"Authentication failed."
# else:
#     sayString = f"Welcome {authenticationOutput}, Authentication successful."

# print(sayString)
# winspeech.say_wait(sayString)