Esempio n. 1
0
def main():
    while True:
        record()
        try:
            text = recognize_audio_file()
            print(text)
            if text.strip() == "play music":
                speak("Which song you want to play?")
                record(seconds=5)
                try:
                    text = recognize_audio_file()
                    speak(f'Finished recording. Playing {text}')
                    play_music(text)

                except sr.UnknownValueError:
                    speak(
                        'I didn\'t recognise the text. Say play music if you want to play music'
                    )

            if text.strip() == 'stop':
                speak("I'm outta here")
                break

            if ''.join(text.strip().split()[:2]) == 'setvolume':
                m = alsaaudio.Mixer()
                current_volume = m.getvolume()
                m.setvolume(int(text.strip().split()[-1]))

        except sr.UnknownValueError:
            continue
Esempio n. 2
0
                def f(screen):
                    def g(screen):
                        return HighScores(self.screen, self.father,
                                          self.total_points)

                    music.play_music(WINMUSIC)
                    return Visual(screen, utils.load_image(WIN), -1, g)
Esempio n. 3
0
def start_scene_1_episode_3(loading=False): 
    universal.say("Next Time on Pandemonium Cycle: The Potion Wars")
    music.play_music(music.THEME)
    universal.say(["Roland and Elise are getting married, and", pwutilities.name(), "is asked to escort Elise to the Lowen Monastery for the wedding. But things get a little bit complicated when an old enemy of Roland's",
    "ambushes them!"])
    universal.set_commands("Press Enter to save")
    universal.set_command_interpreter(pwutilities.end_content_interpreter)
Esempio n. 4
0
def assisstant(command):
    if command == str("Open YT"):
        scraper.youtube()
        speak("Opening Youtube")
    if command == str("Open Music app"):
        scraper.YT_music()
        speak("Opening YT Music")
    if command == str("Open Github"):
        scraper.Github()
        speak("Opening Github")
    if command == str("Enter a task = str"):
        task_input = input(str("Enter a new task: "))
        tasks.text(task_input)
        speak("Changes saved")
    if command == str("Enter a task = int"):
        task_input = input("Enter a new task: ")
        task_input_float = int(float(task_input))
        tasks.text(task_input_float)
        speak("Changes saved")
    if command == str("Encrypt"):
        encrypter_input = input(str("Enter a string to encrypt: "))
        encrypter.encrypt(bytes(encrypter_input, encoding='utf-8'))
        # encrypter_input = message
    if command == str("Decrypt"):
        decrypter_input = input(str("Enter to decrypt: "))
        encrypter.decrypt(bytes(decrypter_input, encoding='utf-8'))
    if command == str("Play some music"):
        music_choice = input(str("Should I open YT Music or Play locally?"))
        if music_choice == str("Play from YT Music"):
            scraper.YT_music()
        elif music_choice == str("Play Locally"):
            # pick an external mp3 player you have
            music.play_music(
                "/home/atif/Documents/MyProjects/Assistant/Music/Post Malone - Better Now.mp3"
            )
Esempio n. 5
0
 def start_episode(self, *startingSceneArgs):
      global postTitleCardFunction, postTitleCardFuncArgs
      universal.get_screen().fill(universal.DARK_GREY)
      music.play_music(self.titleTheme)
      universal.state.player.clear_marks()
      self.init()
      universal.display_text('Episode ' + str(self.num) + ':\n' + self.name, universal.get_world_view(), universal.get_world_view().midleft, isTitle=True)
      universal.acknowledge(self.initialize_episode, *startingSceneArgs)
Esempio n. 6
0
def title_screen(episode=None):
    global firstEpisode, loadingGame
    textSurface = None
    titleImage = None
    try:
        titleImage = pygame.image.load(TITLE_IMAGES[0]).convert()
        titleImage = pygame.transform.scale(titleImage, (pygame.display.Info().current_w, pygame.display.Info().current_h))
    except IOError:
        textSurface = textrect.render_textrect(get_title(), #+ (":" if get_subtitle() != "" else ""), 
                universal.font, universal.worldView, LIGHT_GREY, DARK_GREY, 1)
    except IndexError:
        textSurface = textrect.render_textrect(get_title(), #+ (":" if get_subtitle() != "" else ""), 
                universal.font, universal.worldView, LIGHT_GREY, DARK_GREY, 1)
    titleImages = []
    if os.path.exists(os.path.join(os.getcwd(), 'save')) and '.init.sav' in os.listdir(os.path.join(os.getcwd(), 'save')):
        #townmode.clear_rooms()
        townmode.previousMode = None
        townmode.load_game('.init.sav', preserveLoadName=False)
    else:
        townmode.save_game('.init.sav', preserveSaveName=False)
    assert(episode is not None or firstEpisode is not None)
    if episode is not None:
        firstEpisode = episode
    screen = universal.get_screen()
    worldView = universal.get_world_view()
    background = universal.get_background()
    screen.fill(universal.DARK_GREY)
    font = pygame.font.SysFont(universal.FONT_LIST, 50)
    wvMidLeft = worldView.midleft
    if loadingGame:
        for i in range(1, len(TITLE_IMAGES)):
            try:
                titleImages.append(pygame.image.load(TITLE_IMAGES[i]))
                titleImages[-1] = pygame.transform.scale(titleImages[-1], (pygame.display.Info().current_w, pygame.display.Info().current_h))
            except IOError:
                continue
        opening_crawl()
        loadingGame = False
    music.play_music(music.THEME)
    universal.set_commands(['(S)tart', '(L)oad', '(A)cknowledgments', '(Esc)Quit'])
    universal.set_command_interpreter(title_screen_interpreter)
    if not skip:
        pygame.time.delay(125)
        for i in range(0, len(titleImages)):
            screen.blit(titleImages[i], worldView.topleft)
            pygame.time.delay(25)
            pygame.display.flip()
    if titleImage is not None:
        screen.blit(titleImage, worldView.topleft)
    else:
        screen.blit(textSurface, worldView.centerleft)
    pygame.display.flip()
    while 1:
        universal.textToDisplay = ''
        universal.titleText = ''
        for event in pygame.event.get():
            if event.type == KEYUP:
                return [universal.get_command_view()]
Esempio n. 7
0
 def loop(self):
     pygame.event.clear()
     music.stop_music()
     music.play_music(CREDITSMUSIC)
     self._load_credits()
     self._draw_screen()
     pygame.time.delay(200)
     music.stop_music()
     return self.father
Esempio n. 8
0
 def loop(self):
     pygame.event.clear()
     music.stop_music()
     music.play_music(CREDITSMUSIC)
     self._load_credits()
     self._draw_screen()
     pygame.time.delay(200)
     music.stop_music()
     return self.father
Esempio n. 9
0
def add_music():
    print("music")
    winning_sound = ["f6", "8d#6", "8d6", "8c6", "p", "8g", "8a#", "p", "8d6", "c6", "p", "f6", "8d#6", "8d6", "8c6",
                     "p", "8d6",
                     "8a#", "p", "8d6", "c6", "p", "f6", "8d#6", "8d6", "8c6", "p", "8g", "8a#", "p", "8d6", "c6", "p",
                     "f6",
                     "8d#6",
                     "8d6", "8c6", "p", "8d6", "8a#", "p", "8d6", "c6"]

    play_music(winning_sound, 140, 5)
Esempio n. 10
0
    def main_menu(self):
        # Игровой цикл
        click = False
        while True:
            if not self.playing:
                self.draw()
            else:
                with open("game_end.txt", "r+") as fil:
                    if fil.read():
                        self.playing = False

            # Проверка коллизии кнопки и мыши
            mx, my = pygame.mouse.get_pos()
            if click:
                if self.button_1.collidepoint((mx, my)):
                    g = DveTysyachiSorokVosyem(self.screen)
                    g.play()
                    self.playing = True
                elif self.button_2.collidepoint((mx, my)):
                    g = Tetris(self.screen)
                    g.cycle()
                    self.playing = True
                elif self.button_3.collidepoint((mx, my)):
                    g = FourInARow(6, 7)
                    g.start()
                    self.playing = True
                elif self.button_4.collidepoint((mx, my)):
                    g = TicTacToe(250, 20)
                    g.selection_mode()
                    g.update()
                    g.start()
                    self.playing = True

            click = False
            # Считывание событий с клавиатуры и мыши
            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    exit()
                if event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        pygame.quit()
                        sys.exit()
                if event.type == MOUSEBUTTONDOWN:
                    if event.button == 1:
                        click = True
                if event.type == music.STOPPED_PLAYING:
                    music.play_music()

            pygame.display.update()
            self.cl.tick(60)
Esempio n. 11
0
def town_mode(sayDescription=True):
    """
    Goes into town mode (i.e. displays the commands for town-mode, and says the description of the current location, if sayDescription is True. Otherwise, it doesn't
    say the description.
    """
    room = universal.state.location
    global previousMode
    previousMode = town_mode
    if sayDescription:
        universal.say_title(room.name)
    if sayDescription:
        universal.say_replace(room.get_description())
    universal.set_commands(['(P)arty', '(G)o', '(S)ave', '(Q)uick Save', '(T)alk', '(L)oad', '(Esc)Quit', 't(I)tle Screen'])
    universal.set_command_interpreter(town_mode_interpreter)
    music.play_music(room.bgMusic)
Esempio n. 12
0
    def __init__(self, screen, score):
        music.play_music(MENUMUSIC)
        self.screen = screen
        self.cursor = '!'
        self.text = ""
        self.done = False
        self.font1 = pygame.font.Font(FONT3, 50)
        self.clock = pygame.time.Clock()

        score_text="Your score is "+str(score)
        text_list=["CONGRATULATION !!!","WELCOME TO THE \"HALL OF FAME\"","Please, introduces your name","  ",score_text]
        self.background = HighScores(screen).draw_screen(text_list)
        pygame.display.flip()
        
        self._draw_text()
Esempio n. 13
0
 def loop(self):
     music.stop_music()
     if (not os.path.exists(HISCORES)) and (self.score <= 0):
         text_list=["HIGH SCORE","I\'m sorry","Nobody has been saved.","Nobody has stopped being zombie"]
         music.play_music(PLAYMUSIC)
         self.draw_screen(text_list)
         return self._waitKey()
     else:
         self.top_scores = self._load_score()
         if self.score > 0:
             self._add()
         text_list = self._convert()
         text_list[0:0]=['HIGH SCORES']
         music.play_music(PLAYMUSIC)
         self.draw_screen(text_list)
         return self._waitKey()
Esempio n. 14
0
 def start(self):  # основной цикл
     running = True
     while running:
         for event in pygame.event.get():
             if event.type == pygame.QUIT:
                 running = False
             if event.type == pygame.MOUSEBUTTONDOWN:
                 self.make_move(event.pos, True)
                 self.screen.fill((0, 0, 0))
             if event.type == pygame.KEYDOWN:
                 if event.key == pygame.K_ESCAPE:
                     running = False
                     with open("game_end.txt", "w+") as fil:
                         fil.write("1")
                     break
             if event.type == music.STOPPED_PLAYING:
                 music.play_music()
Esempio n. 15
0
    def loop(self):
        '''Returns the asosiated object for the selected item'''
        pygame.event.clear()
        if not music.is_playing_music():
            music.play_music(MENUMUSIC)
        while (not self.draw_end) and (
                not self.done):  # menu draw the first time

            self.clock.tick(CLOCK_TICS)

            self.screen.blit(self.background, (0, 0))

            if pygame.event.peek([KEYDOWN, KEYUP, QUIT]):
                for event in pygame.event.get():
                    self.control(event)

            self._draw_items()
            pygame.display.flip()

            self.timeloop += 1
            if self.timeloop == 50:
                self.state = 1

        self.draw_end = False
        while not self.done:  # menu draw only if some key is pressed

            self.clock.tick(CLOCK_TICS)

            self.screen.blit(self.background, (0, 0))

            pygame.event.clear()
            event = pygame.event.wait()
            self.control(event)

            self._draw_items()
            pygame.display.flip()

            self.timeloop += 1
            if self.timeloop == 50:
                self.state = 1

        return self.returns[self.index]
Esempio n. 16
0
    def loop(self):
        '''Returns the asosiated object for the selected item'''
        pygame.event.clear()
        if not music.is_playing_music():
            music.play_music(MENUMUSIC)
        while (not self.draw_end) and (not self.done): # menu draw the first time

            self.clock.tick(CLOCK_TICS)

            self.screen.blit(self.background, (0,0))

            if pygame.event.peek([KEYDOWN, KEYUP, QUIT]):
                for event in pygame.event.get():
                    self.control(event)

            self._draw_items()
            pygame.display.flip()

            self.timeloop += 1
            if self.timeloop == 50:
                self.state=1
        
        self.draw_end = False
        while not self.done: # menu draw only if some key is pressed

            self.clock.tick(CLOCK_TICS)

            self.screen.blit(self.background, (0,0))

            pygame.event.clear()
            event = pygame.event.wait()
            self.control(event)

            self._draw_items()
            pygame.display.flip()

            self.timeloop += 1
            if self.timeloop == 50:
                self.state=1
        
        return self.returns[self.index]
Esempio n. 17
0
def main():
    #Initialize 
    pygame.init()
    screen = pygame.display.set_mode((WIDTH, HEIGHT))
    pygame.display.set_caption(WINDOW_TITLE)
    icon = utils.load_image(ICON, (0,0,0))
    pygame.display.set_icon(icon)

    #Introduction
    images = [utils.load_image(image) for image in INTRO_IMAGES]
    visual = Visual(screen, images, INTRO_TIMES)
    music.play_music(INTROMUSIC, 1)
    visual.loop()
    music.stop_music()
    
    #Shooter opcion
    opcion = menu
    while opcion is not exit:
        change = opcion(screen).loop()
        if change:
            opcion = change
    opcion()        #Exit
Esempio n. 18
0
 def render_play(self):
     music.play_music('Chiptune.wav', -1)  # Play background music
     music.play_sample('Bubbles.wav', True)
     self.init_salmon(450, 550)
     self.init_energy_bar()
     # Init river & riverbanks then bring up the HUD:
     self.sp_river = self.factory.from_image(
         RESOURCES.get_path('river.bmp'))
     self.river = sprite_classes.Inert(self.world, self.sp_river, 0, 50)
     self.river.setDepth(1)
     self.sp_river_top = self.factory.from_image(
         RESOURCES.get_path('top.bmp'))
     self.sp_river_bottom = self.factory.from_image(
         RESOURCES.get_path('bottom.bmp'))
     self.river_top = sprite_classes.Enemy(self.world, self.sp_river_top,
                                           (0, 1), 0, -550, False)
     self.river_bottom = sprite_classes.Enemy(self.world,
                                              self.sp_river_bottom, (0, 1),
                                              0, 50, False)
     self.river_top.setDepth(2)
     self.river_bottom.setDepth(2)
     self.dashboard.setDepth(4)
     self.world.process()
Esempio n. 19
0
 def f(screen):
     def g(screen):
         return HighScores(self.screen, self.father, self.total_points)
     music.play_music(WINMUSIC)
     return Visual(screen,utils.load_image(WIN),-1,g)
Esempio n. 20
0
 def run(self):
     t1 = threading.Thread(target=play_music(search_music))
     t1.start()
     got, dur = get_youtube(search_music)
     time.sleep(dur)
Esempio n. 21
0
def tuling_reply(msg):

    #####let robot who is me
    #    if msg['FromUserName'] == my_ID:
    #        return 'I know you'
    #####send command
    #    get_IP = ['*ip','*IP']
    #    for i in get_IP:
    #            if msg['Text'] == i:
    #                (status_cmd,output_cmd) = commands.getstatusoutput('ls')
    #                return u'return : '+str(status_cmd)+u'\nresult : \n' + str(output_cmd)

    #    cf = ConfigParser.ConfigParser()
    #    cf.read('admin.conf')

    #######  get robot switch and admin ID ######### now disable by Pedro
    #    robot_switch = cf.get('switch','RobotSwitch')
    #    my_ID = cf.get('admin','ID')
    #    if msg['Text'].startswith('**'):
    #        cf = ConfigParser.ConfigParser()
    #        cf.read('admin.conf')
    #        stop_cmd = ['baibai','bai','bye','byebye','shutdown','stop','close']
    #        start_cmd = ['hi','hello','open','girl','start']
    #        if robot_switch == 'True':
    #        if True:
    #            for i in stop_cmd:
    #                if i == msg['Text'][2:]:
    #                    cf.set('switch','RobotSwitch','False')
    #                    cf.write(open("admin.conf","w"))
    #                    return 'robot shutdown successfully'
    #
    #        else:
    #            for i in start_cmd:
    #                if i == msg['Text'][2:]:
    #                    cf.set('switch','RobotSwitch','True')
    #                    cf.write(open("admin.conf","w"))
    #                    return 'robot reboot successfully'

    ####send message to admin
    admin_id = itchat.search_friends(name=info.admin_name)[0]['UserName']
    if msg['FromUserName'] != admin_id:
        itchat.send(
            u'I received %s\u2005 %s' %
            (msg['User']['NickName'], msg['Content']), admin_id)

#my_ID will change when you login after logoff
    if msg['Text'].startswith('*'):
        ######  help  ##############
        if msg['Text'][1:] == 'help':
            return '''******************
*help                               --get this message
*setadmin                      --XXXX
speakXXXX                    --speak XXXX by sounder
糗百+页数(1/2/3...)      --爬取糗百纯文本内容
天气+地点                      --查询天气
温度                                 --查询宿舍温度
[音乐]
播放                                 --音乐播放+[歌曲序号]
停止                                 --音乐停止/音乐暂停
更新列表                         --音乐更新
读取列表                         --音乐列表+[列表页数]
[get fil/img/vid/msg]
/Pedro/python/file/    <----file saved in this path when you send /img/vid/fil/voi to it
*get+fil/img/vid/msg+:/!+filepath    <---- if you get the file in /Pedro/python/file/XXX pls use '!',or, use ':' with whole path
******************
'''

######  set admin ID #######
        cf = ConfigParser.ConfigParser()
        cf.read(info.admin_file)
        my_ID = cf.get('admin', 'ID')
        if msg['Text'][1:] == 'setadmin':
            cf.set('admin', 'ID', msg['FromUserName'])
            cf.write(open(info.admin_file, "w"))
            return 'set You as Admin successfully !'

######  if is admin , run command  #######
        if msg['FromUserName'] == my_ID:

            ########music function   not ready#######
            #            if msg['Text'][1:] == 'close':
            #                close_music()
            #                return 'music OFF'
            #            elif msg['Test'][1:6] == 'play:':
            #                itchat.send(interact_select_song(msg['Text'][6:]),my_ID)
            #            else:
            if msg['Text'][1:4] == 'get':
                ##########   *get[img,fil,msg,vid]:[][filename]:[path]
                get_file(msg['Text'][4:7], msg['Text'][7], msg['Text'][8:])
                return 'post file to you successfully,pls check!'
            else:
                (status_cmd,
                 output_cmd) = commands.getstatusoutput(msg['Text'][1:])

                return u'return : ' + str(status_cmd) + u'\nresult : \n' + str(
                    output_cmd)
        else:
            return 'Wrong admin ID, pls check'
#    elif robot_switch == 'True':

######  speak words you send me  #######
    if msg['Text'].startswith('speak'):
        cf = ConfigParser.ConfigParser()
        cf.read(info.admin_file)
        token = cf.get('token', 'key')
        url = 'http://tsn.baidu.com/text2audio?tex="%s"&lan=zh&per=0&pit=1&spd=7&cuid=9805555&ctp=1&tok=%s' % (
            msg['Text'][5:].strip().replace(' ', ',').replace('\n',
                                                              '。'), token)
        os.system('mpg123  "%s" & ' % url)
        return 'speak words successfully'

#########  音乐  #######
    if msg['Text'].startswith(u'音乐'):
        if msg['Text'][2:].startswith(u'暂停') or msg['Text'][2:].startswith(
                u'停止'):
            return music.stop_music()
        elif msg['Text'][2:].startswith(u'更新'):
            return music.update_music()
        elif msg['Text'][2:].startswith(u'列表'):
            if len(msg['Text']) == 4:
                return music.list_music('1')
            else:
                return music.list_music(msg['Text'][4:])

        elif msg['Text'][2:].startswith(u'播放'):
            if len(msg['Text']) == 4:
                return music.play_music('1')
            else:
                return music.play_music(msg['Text'][4:])

#########  temperature  #######
    if msg['Text'].startswith(u'温度'):
        if len(msg['Text']) == 2:
            return str(temperature.temp())

#########  糗百  #######
    if msg['Text'].startswith(u'糗百'):
        if len(msg['Text']) == 2:
            page = '1'
        elif msg['Text'][2:].isdigit():
            page = msg['Text'][2:]
        else:
            page = '1'
        (status_cmd, output_cmd) = commands.getstatusoutput(
            'python /Pedro/python/functions/qiubai.py ' + page)

        return u'return : ' + str(status_cmd) + u'\nresult : \n' + str(
            output_cmd.decode('utf-8'))

########  天气   #######
    if msg['Text'].startswith(u'天气'):
        if len(msg['Text']) == 2:
            local = '东丽'
        else:
            local = msg['Text'][2:]
        (status_cmd, output_cmd) = commands.getstatusoutput(
            'python /Pedro/python/functions/weather.py ' + local)
        if status_cmd != 0:
            return u'天气查询失败,请输入正确地址'
        return u'return : ' + str(status_cmd) + u'\nresult : \n' + str(
            output_cmd.decode('utf-8'))
######### reply in normal #######
    defaultReply = 'I received: ' + msg['Text']
    ######### reply by tuling #######
    reply = get_response(msg['Text'])
    return reply or defaultReply
    return
Esempio n. 22
0
    def loop(self):  
        music.play_music(PLAYMUSIC)
        while not self.finish():
            self.tics += 1  

            if not self.next_scream:
                music.play_random_scream()            
                self.next_scream = random.randrange(400,500)
            else:
                self.next_scream -= 1               
   
            self.screen.blit(self.background, (-(self.tics % 700),0)) 
            self.update()
            self.draw()

            #Control
            for event in pygame.event.get():
                self.control(event)

            self.clock.tick(CLOCK_TICS)

            if self.control_down == 0: self.hero.down()
            if self.control_up == 0: self.hero.up()
            if self.control_right == 0: self.hero.right()
            if self.control_left == 0: self.hero.left()

            if self.control_down >= 0:
                self.control_down += 1
                if self.control_down >= self.control_tiempo:
                    self.control_down = 0
                    
            if self.control_up >= 0:
                self.control_up += 1
                if self.control_up >= self.control_tiempo:
                    self.control_up = 0

            if self.control_right >= 0:
                self.control_right += 1
                if self.control_right >= self.control_tiempo:
                    self.control_right = 0

            if self.control_left >= 0:
                self.control_left += 1
                if self.control_left >= self.control_tiempo:
                    self.control_left = 0

            self.clock.tick(CLOCK_TICS)

            pygame.display.flip()
    
        if self.exit:
            return self.father
        elif not self.level_time.seconds:                   
            #music.stop_music()

            if self.level < LEVELS:
                def f(screen):
                    return Level(screen, self.father, self.level + 1, self.total_points)
                return f
            else:
                
                def f(screen):
                    def g(screen):
                        return HighScores(self.screen, self.father, self.total_points)
                    music.play_music(WINMUSIC)
                    return Visual(screen,utils.load_image(WIN),-1,g)
                return f

        elif self.energy_bar.energy_percent <= 0:
            def f(screen):
                def g(screen):
                    return HighScores(self.screen, self.father, self.total_points) 
                music.play_gameover()
                return Visual(screen, [utils.load_image(GAMEOVER)], [3], g)               

            return f
Esempio n. 23
0
def process(query):

    if 'play' in query and 'music' not in query:
        answer = get_answer_from_memory('play')
    else:
        answer = get_answer_from_memory(query)

    if answer == "get time details":
        return ("Time is " + get_time())

    elif answer == "check internet connection":
        if check_internet_connection():
            return "internet is connected"
        else:
            return "internet is not connected"

    elif answer == "tell date":
        return "Date is " + get_date()

    elif answer == "on speak":
        return turn_on_speech()

    elif answer == "off speak":
        return turn_off_speech()

    elif answer == "close browser":
        close_browser()
        return "closing browser"

    elif answer == "open facebook":
        open_facebook()
        return "opening facebook"

    elif answer == "open google":
        open_google()
        return "opening google"

    elif answer == "play music":
        return play_music()

    elif answer == 'play':
        return play_specific_song(query)

    elif answer == "pause music":
        return pause_music()

    elif answer == "stop music":
        return stop_music()

    elif answer == "next song":
        return next_song()

    elif answer == "previous song":
        return previous_song()

    elif answer == 'change wallpaper':
        return change_wallpaper()

    elif answer == 'get news':
        return get_news()

    elif answer == 'change name':
        output("Okay! what do you want to call me")
        temp = take_input()
        if temp == assistant_details.name:
            return "Can't change. I think you're happy with my old name"
        else:
            update_name(temp)
            assistant_details.name = temp
            return "Now you can call me " + temp

    else:
        output("Dont know this one should i search on internet?")
        ans = take_input()
        if "yes" in ans:
            answer = check_on_wikipedia(query)
            if answer != "":
                return answer

        else:
            output("can you please tell me what it means?")
            ans = take_input()
            if "it means" in ans:
                ans = ans.replace("it means", "")
                ans = ans.strip()

                value = get_answer_from_memory(ans)
                if value == "":
                    return "Can't help with this one "

                else:
                    insert_question_and_answer(query, value)
                    return "Thanks i will remember it for the next time"

            else:
                return "can't help with this one"
    train.run_recognizer()
else:
    face_list = []
    while True:
        ret, frame = video_capture.read()
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8, 8))
        clahe_image = clahe.apply(gray)
        face = facecascade.detectMultiScale(clahe_image,
                                            scaleFactor=1.1,
                                            minNeighbors=15,
                                            minSize=(10, 10),
                                            flags=cv2.CASCADE_SCALE_IMAGE)
        if len(face) == 1:
            faceslice = crop_face(gray, face)
            face_list.append(faceslice)
            if len(face_list) == 10:
                break

    fishface.read('Model/model.cv2')
    emotion_list = []
    max = 0
    correct_emotion = 0
    for face in face_list:
        emotion, confidence = fishface.predict(face)
        if confidence > max:
            correct_emotion = emotion
            max = confidence

    music.play_music(emotions[correct_emotion])
Esempio n. 25
0
    def selection_mode(self,
                       selecting_player_numbers=True
                       ):  # выбор режима и сложности

        button_size = self.width // 4, 7 * self.width // 4 // 20

        def on_button_1(pos):
            x = pos[0]
            y = pos[1]
            if self.width // 2 - self.width // 8 < x < self.width // 2 + button_size[0] \
                    and self.height // 2 - 100 < y < self.height // 2 - 100 + button_size[1]:
                return True
            return False

        def on_button_2(pos):
            x = pos[0]
            y = pos[1]
            if self.width // 2 - self.width // 8 < x < self.height // 2 + button_size[0] \
                    and self.height // 2 < y < self.height // 2 + button_size[1]:
                return True
            return False

        class PlayerButton(pygame.sprite.Sprite):  # кнопка
            def __init__(self, coords, image, image_fon, *groups):
                super().__init__(*groups)
                x, y = coords
                self.image = pygame.transform.scale(load_image(image),
                                                    button_size)
                self.image_normal = pygame.transform.scale(
                    load_image(image), button_size)
                self.image_fon = pygame.transform.scale(
                    load_image(image_fon), button_size)
                self.turn = True
                self.rect = self.image.get_rect()
                self.rect.x = x
                self.rect.y = y

            def update(self):  # подсветка при наведении курсора
                if self.turn:
                    self.image = self.image_fon
                    self.turn = False
                else:
                    self.image = self.image_normal
                    self.turn = True

        coords_1 = self.width // 2 - self.width // 8, self.height // 2 - 100
        coords_2 = self.width // 2 - self.width // 8, self.height // 2

        sprites_1 = pygame.sprite.Group()
        if selecting_player_numbers:  # если выбор количества игроков, то картинки с нужной надписью
            button1_name = "1pl.png"
            button1_fon_name = "1pl_fon.png"
            button2_name = "2pl.png"
            button2_fon_name = "2pl_fon.png"
            fon_name = "selection_mode.png"
        else:
            button1_name = "hard.png"
            button1_fon_name = "hard_fon.png"
            button2_name = "easy.png"
            button2_fon_name = "easy_fon.png"
            fon_name = "difficulty_selection.png"

        fon = pygame.transform.scale(load_image(fon_name),
                                     (self.width, self.height))

        PlayerButton(coords_1, button1_name, button1_fon_name, sprites_1)
        sprites_2 = pygame.sprite.Group()
        PlayerButton(coords_2, button2_name, button2_fon_name, sprites_2)
        sprites_1_fon = True
        sprites_2_fon = True
        sprites_1.draw(self.screen)
        sprites_2.draw(self.screen)

        while True:
            if on_button_1(pygame.mouse.get_pos()) and sprites_1_fon:
                sprites_1_fon = False
                sprites_1.update()
            elif not on_button_1(pygame.mouse.get_pos()) and not sprites_1_fon:
                sprites_1_fon = True
                sprites_1.update()
            if on_button_2(pygame.mouse.get_pos()) and sprites_2_fon:
                sprites_2.update()
                sprites_2_fon = False
            elif not on_button_2(pygame.mouse.get_pos()) and not sprites_2_fon:
                sprites_2_fon = True
                sprites_2.update()

            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    terminate()
                elif event.type == pygame.MOUSEBUTTONDOWN:
                    if on_button_1(event.pos):
                        if selecting_player_numbers:
                            self.vs_computer = True
                            self.selection_mode(False)
                            return
                        self.difficulty = 1
                        self.screen.fill((0, 0, 0))
                        return
                    elif on_button_2(event.pos):
                        if selecting_player_numbers:
                            self.vs_computer = False
                            self.screen.fill((0, 0, 0))
                            return
                        self.difficulty = 0
                        self.screen.fill((0, 0, 0))
                        return
                if event.type == music.STOPPED_PLAYING:
                    music.play_music()

            self.screen.fill((0, 0, 0))
            self.screen.blit(fon, (0, 0))
            sprites_1.draw(self.screen)
            sprites_2.draw(self.screen)

            pygame.display.flip()
Esempio n. 26
0
def load_level():
    screen.blit_UI(loading, (0, 0))
    pygame.display.flip()
    global spider
    global frames
    frames = 0
    movement.clear()
    bird.clear()
    bomb.clear()
    flingable.clear()
    frog.clear()
    hand.clear()
    stinger.clear()
    venom.clear()
    wasp.clear()
    screen.reset()

    start_region = movement.WalkableRegion("tree4", topleft=(0, 0))
    movement.WalkableRegion("tree branch", center=(1085, 360))
    movement.WalkableRegion("web bridge", center=(2125, 810))
    movement.WalkableRegion("web bridge", center=(2695, 107))
    movement.WalkableRegion("web bridge", center=(4135, 660))
    movement.WalkableRegion("tree branch", center=(4785, 295))
    movement.WalkableRegion("tree branch", center=(4785, 510))
    movement.WalkableRegion("tree branch", center=(4785, 725))
    movement.WalkableRegion("tree2", topleft=(520, 0))
    movement.WalkableRegion("tree3", topleft=(725, 0))
    movement.WalkableRegion("tree1", topleft=(1205, 0))
    movement.WalkableRegion("tree1", topleft=(1680, 0))
    movement.WalkableRegion("tree1", topleft=(2235, 0))
    movement.WalkableRegion("tree4", topleft=(2810, 0))
    movement.WalkableRegion("tree3", topleft=(3320, 0))
    movement.WalkableRegion("tree1", topleft=(3735, 0))
    movement.WalkableRegion("tree4", topleft=(4207, 0))
    movement.WalkableRegion("tree4", topleft=(4915, 0))
    movement.WalkableRegion("bathroom toothbrush", topleft=(5357, 0))
    movement.WalkableRegion("bathroom sink", topleft=(6268, 0))
    movement.WalkableRegion("bathroom window", topleft=(7362, 0))
    movement.WalkableRegion("window", topleft=(5357, 0))

    flingable.Flingable("rock", (645, 410))
    flingable.Flingable("acorn", (1310, 140))
    flingable.Flingable("acorn", (1403, 175))
    flingable.Flingable("acorn", (1482, 205))
    flingable.Flingable("acorn", (1400, 267))
    flingable.Flingable("rock", (1310, 635))
    flingable.Flingable("rock", (1430, 665))
    flingable.Flingable("branch", (1430, 735))
    flingable.Flingable("rock", (1807, 293))
    flingable.Flingable("rock", (1770, 410))
    flingable.Flingable("acorn", (1870, 450))
    flingable.Flingable("acorn", (2395, 205))
    flingable.Flingable("rock", (2460, 710))
    flingable.Flingable("branch", (2410, 535))
    flingable.Flingable("acorn", (2935, 230))
    flingable.Flingable("rock", (3075, 330))
    flingable.Flingable("rock", (2945, 500))
    flingable.Flingable("acorn", (3105, 505))
    flingable.Flingable("rock", (3040, 700))
    flingable.Flingable("acorn", (3475, 335))
    flingable.Flingable("rock", (3805, 325))
    flingable.Flingable("rock", (3960, 460))
    flingable.Flingable("rock", (3840, 615))
    flingable.Flingable("rock", (4345, 390))
    flingable.Flingable("rock", (4540, 500))
    flingable.Flingable("branch", (4435, 720))

    wasp.Wasp(1100, 235)
    wasp.Wasp(1155, 500)
    wasp.Wasp(1255, 265)
    wasp.Wasp(1940, 165)
    wasp.Wasp(1940, 320)
    wasp.Wasp(1940, 410)
    wasp.Wasp(1940, 775)
    wasp.Wasp(2372, 320)
    wasp.Wasp(2640, 475)
    wasp.Wasp(2760, 630)
    wasp.Wasp(2815, 355)
    wasp.Wasp(2865, 805)
    wasp.Wasp(3685, 680)
    wasp.Wasp(4105, 345)
    wasp.Wasp(4490, 205)
    wasp.Wasp(4665, 555)
    wasp.Wasp(4785, 725)
    wasp.Wasp(4940, 610)
    wasp.Wasp(4995, 270)
    wasp.Wasp(5100, 470)
    wasp.Wasp(5195, 730)
    wasp.Wasp(6135, 760)
    wasp.Wasp(6770, 360)
    wasp.Wasp(7320, 280)
    wasp.Wasp(7640, 700)

    high = -10, 10
    med = -15, 15
    low = -18, 18
    bird.Bird((2675, 100), med, -.25)
    bird.Bird((3705, 100), high, -.25)
    bird.Bird((3925, 100), low, -.25)
    bird.Bird((4635, 100), low, -.25)
    bird.Bird((4995, 100), med, -.25)
    bird.Bird((5315, 100), high, -.25)

    frog.Frog((1850, 980))
    frog.Frog((3250, 980))
    frog.Frog((3915, 980))
    frog.Frog((4455, 980))
    frog.Frog((4788, 980))
    frog.Frog((5135, 980))

    spider = Spider(start_region)
    music.music_begin()
    music.play_music()
Esempio n. 27
0
    def start(self):  # основной цикл
        pygame.display.update()
        game_over = False
        running = True
        myfont = pygame.font.SysFont("monospace", 75)

        turn = random.randint(PLAYER, AI)

        while not game_over and running:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    sys.exit()

                if event.type == pygame.MOUSEMOTION:  # отрисовываем шарик, который собираемся бросать
                    pygame.draw.rect(self.screen, BLACK,
                                     (0, 0, self.width, SQUARESIZE))
                    posx = event.pos[0]
                    if turn == PLAYER:
                        pygame.draw.circle(self.screen, RED,
                                           (posx, int(SQUARESIZE / 2)), RADIUS)

                pygame.display.update()

                if event.type == pygame.MOUSEBUTTONDOWN:  # игрок делает ход
                    pygame.draw.rect(self.screen, BLACK,
                                     (0, 0, self.width, SQUARESIZE))
                    if turn == PLAYER:
                        posx = event.pos[0]
                        col = int(math.floor(posx / SQUARESIZE))

                        if self.is_valid_location(self.board, col):
                            row = self.get_next_open_row(self.board, col)
                            self.drop_piece(self.board, row, col, PLAYER_PIECE)

                            if self.winning_move(self.board, PLAYER_PIECE):
                                label = myfont.render("Красный победил!", True,
                                                      RED)
                                self.screen.blit(label, (40, 10))
                                game_over = True

                            turn += 1
                            turn = turn % 2

                            self.draw_board(self.board)
                if event.type == pygame.KEYDOWN:
                    if event.key == pygame.K_ESCAPE:
                        running = False
                        with open("game_end.txt", "w+") as fil:
                            fil.write("1")
                        break
                if event.type == music.STOPPED_PLAYING:
                    music.play_music()
            if running:
                if turn == AI and not game_over:  # компьютер делает ход
                    col, minimax_score = self.minimax(self.board, 5, -math.inf,
                                                      math.inf, True)

                    if self.is_valid_location(self.board, col):
                        row = self.get_next_open_row(self.board, col)
                        self.drop_piece(self.board, row, col, AI_PIECE)

                        if self.winning_move(self.board, AI_PIECE):
                            label = myfont.render("Желтый победил!", True,
                                                  YELLOW)
                            self.screen.blit(label, (40, 10))
                            game_over = True

                        self.draw_board(self.board)

                        turn += 1
                        turn = turn % 2

                if game_over:
                    pygame.time.wait(3000)
Esempio n. 28
0
    try:
        str = r.recognize_google(audio)
        str = str.lower()
        print(str)
        li = []

        def get_words(str):
            li = str.split()
            return li

        li = get_words(str)

        if "open" in li or "Open" in li or "close" in li or "back" in li or "organise" in li:
            ffo.opening(li)
        elif ("play" in li or "Play" in li) and ("music" in li
                                                 or "Music" in li):
            print("play kro bhai")
            music.play_music(li[1])
        elif "switch" in li:
            utilities.tabs_switching_operation()
        elif "search" in li and "google" in li:
            google_surf.search()
        elif "bye" in li:
            break
    except sr.UnknownValueError:
        print("Google Speech Recognition could not understand audio")
    except sr.RequestError as e:
        print(
            "Could not request results from Google Speech Recognition service; {0}"
            .format(e))
Esempio n. 29
0
def opening_crawl():
    #universal.say_replace([
    #"You've been stabbed in the stomach. Your health magic triggers."])
    #display_crawl()
    #delay_short()  
    #universal.say_replace("But there's no damage to repair.")
    #display_crawl()
    #delay_short()
    universal.say_replace(['''Pandemonium Cycle: The Potion Wars is intended for adults only. Spanking and other erotic content depicted are fantasies and intended for''',
    '''adults only. Nothing in this game should be interpreted as''', 
    '''advocating any form of non-consensual spanking or the spanking of minors. I firmly believe that non-consensual violence in any relationship is abuse.''',
    '''\n-Andrew Russell''',
    '''\n\nTo skip the opening crawl (which will begin shortly), press Enter at any time.\n\n''',
    '''This game does make some use of colors to provide information. If you are colorblind, please let me know so that I can develop alternatives. Thank you.'''])
    display_crawl()
    delay()
    if not skip:
        music.play_music(OPENING_CRAWL, fadeoutTime=0, wait=True)
    universal.say_replace(["Along the coast of the Medios Sea is a region rife with bickering city-states, known collectively as the Thousin Cities. The city-states are inhabited by two broad cultures: the bronze-skinned "
        "Taironans, and the much paler Carnutians."])
    display_crawl()
    delay()
    universal.say_replace(["Magic permeates this world, like oxygen permeates our own. Just as we have adapted to use oxygen, so have they adapted to use magic.",
        "They instinctively use magic to strengthen their bodies, making the average person faster, stronger, and more perceptive than our greatest athletes. Each has a",
        "special store of magic, called health, that allows them to instantly heal serious injuries."])
    display_crawl()
    delay_long()
    universal.say_replace(["However, there is a terrible and feared disease called the Wasting Wail. So long as someone is inflicted with the Wail, their body believes",
    "they are covered in terrible wounds, and tries to heal these nonexistent injuries. Their body heals, and heals, until they have no more health. Then, the body",
    "pulls energy from other places, and continues healing, until either they are lucky, and the disease passes, or if they are unlucky, they die."])
    display_crawl()
    delay_long()
    universal.say_replace(["In the year 1273, the Wasting Wail descended upon the Taironan city of Bonda. It started in the Merchant District, spread into the slums, and",
    "even touched the nobility. The other cities instituted a strict quarantine, and left Bonda alone to endure the ravages of the plague"])
    display_crawl()
    delay_long()
    universal.say_replace(["But then, a group of Brothers and Sisters from the Matirian Church, a powerful (Carnutian) religion arrived at the gates of Bonda. They",
    "carried with them a new invention: Potions."])
    display_crawl()
    delay()
    universal.say_replace(["These Potions, they claimed, were healers in a bottle. They would keep the plague",
            "victims' energy up long enough for them to recover. Out of sheer desperation, the Bondan king allowed the healers into",
            "the city."])
    display_crawl()
    delay_long()
    universal.say_replace(["The death rate dropped from 40% to 5%. When the plague finally ended, there was",
            "a massive celebration throughout the city. Bonda and Avaricum prepared to enter an everlasting",
            "alliance. The Matirian Brothers and Sisters stopped distributing Potions."])
    display_crawl()
    delay_long()
    universal.say_replace([
            "The earliest recipients of the Potions",
            "sank into a deep depression. They couldn't sleep, they could barely",
            "eat, they shook uncontrollably, and some",
            "suffered severe seizures. Crowds gathered outside the Matirian treatment centers,",
            "but", 
            "the Matirians didn't have enough Potions to handle this new, strange disease.",
            "Some began to accuse the Matirians of holding out. Others claimed that the Potions",
            "were poison, part of an Avaricumite plot to conquer Bonda."])
    display_crawl()
    delay_long()
    universal.say_replace("The crowds turned into mobs.")
    display_crawl()
    delay_short()
    universal.say_replace(["Treatment centers were attacked. Brothers and Sisters viciously beaten. Bondan",
            "fought Bondan, brother against sister, for the precious few remaining Potions.",
            "An Avaricumite army arrived and occupied Bonda, helping the Brothers and Sisters",
            "escape."])
    display_crawl()
    delay_long()
    universal.say_replace("A little over twenty years have passed. Bonda has all but collapsed, and Avaricum teeters on the edge of a")
    display_crawl()
    delay_short()
    if not skip:
        music.play_music(OPENING_CRAWL, fadeoutTime=0, wait=True)
        pygame.mixer.music.load(music.THEME)
        #music.play_music(music.THEME, DELAY_TIME_SHORT, wait=True)
    else:
        music.play_music(music.THEME, wait=True)
    delay_short()
Esempio n. 30
0
                    g.selection_mode()
                    g.update()
                    g.start()
                    self.playing = True

            click = False
            # Считывание событий с клавиатуры и мыши
            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    exit()
                if event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        pygame.quit()
                        sys.exit()
                if event.type == MOUSEBUTTONDOWN:
                    if event.button == 1:
                        click = True
                if event.type == music.STOPPED_PLAYING:
                    music.play_music()

            pygame.display.update()
            self.cl.tick(60)


if __name__ == '__main__':
    # Запуск музыки и меню
    music.play_music()
    m = Menu()
    m.main_menu()
Esempio n. 31
0
    def loop(self):
        music.play_music(PLAYMUSIC)
        while not self.finish():
            self.tics += 1

            if not self.next_scream:
                music.play_random_scream()
                self.next_scream = random.randrange(400, 500)
            else:
                self.next_scream -= 1

            self.screen.blit(self.background, (-(self.tics % 700), 0))
            self.update()
            self.draw()

            #Control
            for event in pygame.event.get():
                self.control(event)

            self.clock.tick(CLOCK_TICS)

            if self.control_down == 0: self.hero.down()
            if self.control_up == 0: self.hero.up()
            if self.control_right == 0: self.hero.right()
            if self.control_left == 0: self.hero.left()

            if self.control_down >= 0:
                self.control_down += 1
                if self.control_down >= self.control_tiempo:
                    self.control_down = 0

            if self.control_up >= 0:
                self.control_up += 1
                if self.control_up >= self.control_tiempo:
                    self.control_up = 0

            if self.control_right >= 0:
                self.control_right += 1
                if self.control_right >= self.control_tiempo:
                    self.control_right = 0

            if self.control_left >= 0:
                self.control_left += 1
                if self.control_left >= self.control_tiempo:
                    self.control_left = 0

            self.clock.tick(CLOCK_TICS)

            pygame.display.flip()

        if self.exit:
            return self.father
        elif not self.level_time.seconds:
            #music.stop_music()

            if self.level < LEVELS:

                def f(screen):
                    return Level(screen, self.father, self.level + 1,
                                 self.total_points)

                return f
            else:

                def f(screen):
                    def g(screen):
                        return HighScores(self.screen, self.father,
                                          self.total_points)

                    music.play_music(WINMUSIC)
                    return Visual(screen, utils.load_image(WIN), -1, g)

                return f

        elif self.energy_bar.energy_percent <= 0:

            def f(screen):
                def g(screen):
                    return HighScores(self.screen, self.father,
                                      self.total_points)

                music.play_gameover()
                return Visual(screen, [utils.load_image(GAMEOVER)], [3], g)

            return f