diff --git a/Code-Sleep-Python/Bird_migration/requirements.txt b/Code-Sleep-Python/Bird_migration/requirements.txt index 4540164..a225a6b 100644 --- a/Code-Sleep-Python/Bird_migration/requirements.txt +++ b/Code-Sleep-Python/Bird_migration/requirements.txt @@ -1,7 +1,7 @@ cycler==0.10.0 kiwisolver==1.1.0 matplotlib==3.1.1 -numpy==1.17.3 +numpy==1.22.0 pandas==0.25.2 pyparsing==2.4.2 python-dateutil==2.8.0 diff --git a/Code-Sleep-Python/Classification/requirements.txt b/Code-Sleep-Python/Classification/requirements.txt index 3922f12..2c970b0 100644 --- a/Code-Sleep-Python/Classification/requirements.txt +++ b/Code-Sleep-Python/Classification/requirements.txt @@ -1,4 +1,4 @@ -numpy==1.13.3 +numpy==1.22.0 pandas==0.21.0 matplotlib==2.1.0 scikit-learn==0.19.1 \ No newline at end of file diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/blue1.png b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/blue1.png new file mode 100644 index 0000000..d82802a Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/blue1.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/blue2.png b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/blue2.png new file mode 100644 index 0000000..034b76c Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/blue2.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/blue3.png b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/blue3.png new file mode 100644 index 0000000..900d012 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/blue3.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/red1.png b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/red1.png new file mode 100644 index 0000000..e853b95 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/red1.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/red2.png b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/red2.png new file mode 100644 index 0000000..a915f7e Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/red2.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/red3.png b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/red3.png new file mode 100644 index 0000000..f9ed856 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/red3.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/yellow1.png b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/yellow1.png new file mode 100644 index 0000000..e9e1c77 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/yellow1.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/yellow2.png b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/yellow2.png new file mode 100644 index 0000000..2ca3c2d Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/yellow2.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/yellow3.png b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/yellow3.png new file mode 100644 index 0000000..2f693da Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Grumpy/yellow3.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Score/0.png b/Code-Sleep-Python/Flappy Bird/Assets/Score/0.png new file mode 100644 index 0000000..ad522b9 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Score/0.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Score/1.png b/Code-Sleep-Python/Flappy Bird/Assets/Score/1.png new file mode 100644 index 0000000..55d7c89 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Score/1.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Score/2.png b/Code-Sleep-Python/Flappy Bird/Assets/Score/2.png new file mode 100644 index 0000000..6a3af46 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Score/2.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Score/3.png b/Code-Sleep-Python/Flappy Bird/Assets/Score/3.png new file mode 100644 index 0000000..13d88bf Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Score/3.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Score/4.png b/Code-Sleep-Python/Flappy Bird/Assets/Score/4.png new file mode 100644 index 0000000..51cbbc3 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Score/4.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Score/5.png b/Code-Sleep-Python/Flappy Bird/Assets/Score/5.png new file mode 100644 index 0000000..b5055ab Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Score/5.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Score/6.png b/Code-Sleep-Python/Flappy Bird/Assets/Score/6.png new file mode 100644 index 0000000..dbc4c00 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Score/6.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Score/7.png b/Code-Sleep-Python/Flappy Bird/Assets/Score/7.png new file mode 100644 index 0000000..04658ad Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Score/7.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Score/8.png b/Code-Sleep-Python/Flappy Bird/Assets/Score/8.png new file mode 100644 index 0000000..f053e38 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Score/8.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/Score/9.png b/Code-Sleep-Python/Flappy Bird/Assets/Score/9.png new file mode 100644 index 0000000..3bd0412 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/Score/9.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/background-day.png b/Code-Sleep-Python/Flappy Bird/Assets/background-day.png new file mode 100644 index 0000000..afcb5ec Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/background-day.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/background-night.png b/Code-Sleep-Python/Flappy Bird/Assets/background-night.png new file mode 100644 index 0000000..e2a2b89 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/background-night.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/base.png b/Code-Sleep-Python/Flappy Bird/Assets/base.png new file mode 100644 index 0000000..c374f2b Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/base.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/flappybird.png b/Code-Sleep-Python/Flappy Bird/Assets/flappybird.png new file mode 100644 index 0000000..d74f2cf Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/flappybird.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/gameover.png b/Code-Sleep-Python/Flappy Bird/Assets/gameover.png new file mode 100644 index 0000000..b1df7f5 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/gameover.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/pipe-green.png b/Code-Sleep-Python/Flappy Bird/Assets/pipe-green.png new file mode 100644 index 0000000..4664401 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/pipe-green.png differ diff --git a/Code-Sleep-Python/Flappy Bird/Assets/pipe-red.png b/Code-Sleep-Python/Flappy Bird/Assets/pipe-red.png new file mode 100644 index 0000000..ab6e065 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Assets/pipe-red.png differ diff --git a/Code-Sleep-Python/Flappy Bird/README.md b/Code-Sleep-Python/Flappy Bird/README.md new file mode 100644 index 0000000..e4d44d6 --- /dev/null +++ b/Code-Sleep-Python/Flappy Bird/README.md @@ -0,0 +1,39 @@ +# Flappy Bird + +[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com) +[![forthebadge](https://forthebadge.com/images/badges/built-with-swag.svg)](https://forthebadge.com) +[![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://forthebadge.com) + +Flappy Bird is an implementation of the famous flappy bird game in pygame. The game is specifically meant to run on pydroid3 on android, It may not work properly in desktop. + +Install pydroid3 on Android from here : [pydroid3 playstore](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3&hl=en_IN&gl=US) + +![Alt text](app.webp?raw=true "Flappy Bird") + +## How to Download + +Download this project from here [Download Flappy Bird](https://downgit.github.io/#/home?url=https://github.com/pyGuru123/Python-Games/tree/master/Flappy%20Bird) + +## Requirements + +Use the package manager [pip](https://pip.pypa.io/en/stable/) to install following packages :- +* Pygame + +```bash +pip install pygame +``` + +pygame is already installed in pydroid3, no installation required. + +## Usage + +Navigate and click main.py to open the game in pydroid3, tap anywhere to start the game. The objective of the game is jump and pass through the poles without touching them. + +Controls: +* Tap on the screen to make the bird jump. + +## Contributing + +Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. + +Please make sure to update tests as appropriate. \ No newline at end of file diff --git a/Code-Sleep-Python/Flappy Bird/Sounds/die.wav b/Code-Sleep-Python/Flappy Bird/Sounds/die.wav new file mode 100644 index 0000000..9b79fbd Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Sounds/die.wav differ diff --git a/Code-Sleep-Python/Flappy Bird/Sounds/hit.wav b/Code-Sleep-Python/Flappy Bird/Sounds/hit.wav new file mode 100644 index 0000000..9d9b77c Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Sounds/hit.wav differ diff --git a/Code-Sleep-Python/Flappy Bird/Sounds/point.wav b/Code-Sleep-Python/Flappy Bird/Sounds/point.wav new file mode 100644 index 0000000..9cf19fe Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Sounds/point.wav differ diff --git a/Code-Sleep-Python/Flappy Bird/Sounds/swoosh.wav b/Code-Sleep-Python/Flappy Bird/Sounds/swoosh.wav new file mode 100644 index 0000000..bcae63e Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Sounds/swoosh.wav differ diff --git a/Code-Sleep-Python/Flappy Bird/Sounds/wing.wav b/Code-Sleep-Python/Flappy Bird/Sounds/wing.wav new file mode 100644 index 0000000..9ae2c67 Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/Sounds/wing.wav differ diff --git a/Code-Sleep-Python/Flappy Bird/app.webp b/Code-Sleep-Python/Flappy Bird/app.webp new file mode 100644 index 0000000..67672ad Binary files /dev/null and b/Code-Sleep-Python/Flappy Bird/app.webp differ diff --git a/Code-Sleep-Python/Flappy Bird/main.py b/Code-Sleep-Python/Flappy Bird/main.py new file mode 100644 index 0000000..ab54e93 --- /dev/null +++ b/Code-Sleep-Python/Flappy Bird/main.py @@ -0,0 +1,160 @@ +import pygame +import random + +from objects import Grumpy, Pipe, Base, Score + +# Setup ******************************************* + +pygame.init() +SCREEN = WIDTH, HEIGHT = 288, 512 +display_height = 0.80 * HEIGHT +info = pygame.display.Info() +width = info.current_w +height = info.current_h + +if width >= height: + win = pygame.display.set_mode(SCREEN, pygame.NOFRAME) +else: + win = pygame.display.set_mode( + SCREEN, pygame.NOFRAME | pygame.SCALED | pygame.FULLSCREEN) + +clock = pygame.time.Clock() +FPS = 60 + +# COLORS + +RED = (255, 0, 0) +WHITE = (255, 255, 255) +BLACK = (0, 0, 0) + +# Backgrounds + +bg1 = pygame.image.load('Assets/background-day.png') +bg2 = pygame.image.load('Assets/background-night.png') + +bg = random.choice([bg1, bg2]) +im_list = [pygame.image.load('Assets/pipe-green.png'), + pygame.image.load('Assets/pipe-red.png')] +pipe_img = random.choice(im_list) + +gameover_img = pygame.image.load('Assets/gameover.png') +flappybird_img = pygame.image.load('Assets/flappybird.png') +flappybird_img = pygame.transform.scale(flappybird_img, (200, 80)) + +# Sounds & fx + + +die_fx = pygame.mixer.Sound('Sounds/die.wav') +hit_fx = pygame.mixer.Sound('Sounds/hit.wav') +point_fx = pygame.mixer.Sound('Sounds/point.wav') +swoosh_fx = pygame.mixer.Sound('Sounds/swoosh.wav') +wing_fx = pygame.mixer.Sound('Sounds/wing.wav') + +# Objects + +pipe_group = pygame.sprite.Group() +base = Base(win) +score_img = Score(WIDTH // 2, 50, win) +grumpy = Grumpy(win) + +# Variables + +base_height = 0.80 * HEIGHT +speed = 0 +game_started = False +game_over = False +restart = False +score = 0 +start_screen = True +pipe_pass = False +pipe_frequency = 1600 + +running = True +while running: + win.blit(bg, (0, 0)) + + if start_screen: + speed = 0 + grumpy.draw_flap() + base.update(speed) + win.blit(flappybird_img, (40, 50)) + else: + + if game_started and not game_over: + + next_pipe = pygame.time.get_ticks() + if next_pipe - last_pipe >= pipe_frequency: + y = display_height // 2 + pipe_pos = random.choice(range(-100, 100, 4)) + height = y + pipe_pos + + top = Pipe(win, pipe_img, height, 1) + bottom = Pipe(win, pipe_img, height, -1) + pipe_group.add(top) + pipe_group.add(bottom) + last_pipe = next_pipe + + pipe_group.update(speed) + base.update(speed) + grumpy.update() + score_img.update(score) + + if (pygame.sprite.spritecollide(grumpy, pipe_group, False) or + grumpy.rect.top <= 0): + game_started = False + if grumpy.alive: + hit_fx.play() + die_fx.play() + grumpy.alive = False + grumpy.theta = grumpy.vel * -2 + + if grumpy.rect.bottom >= display_height: + speed = 0 + game_over = True + + if len(pipe_group) > 0: + p = pipe_group.sprites()[0] + if (grumpy.rect.left > p.rect.left and + grumpy.rect.right < p.rect.right and not pipe_pass + and grumpy.alive): + pipe_pass = True + + if pipe_pass: + if grumpy.rect.left > p.rect.right: + pipe_pass = False + score += 1 + point_fx.play() + + if not grumpy.alive: + win.blit(gameover_img, (50, 200)) + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_ESCAPE or \ + event.key == pygame.K_q: + running = False + if event.type == pygame.MOUSEBUTTONDOWN: + if start_screen: + game_started = True + speed = 2 + start_screen = False + + game_over = False + last_pipe = pygame.time.get_ticks() - pipe_frequency + next_pipe = 0 + pipe_group.empty() + + speed = 2 + score = 0 + + if game_over: + start_screen = True + grumpy = Grumpy(win) + pipe_img = random.choice(im_list) + bg = random.choice([bg1, bg2]) + + clock.tick(FPS) + pygame.display.update() +pygame.quit() diff --git a/Code-Sleep-Python/Flappy Bird/objects.py b/Code-Sleep-Python/Flappy Bird/objects.py new file mode 100644 index 0000000..8c0d813 --- /dev/null +++ b/Code-Sleep-Python/Flappy Bird/objects.py @@ -0,0 +1,153 @@ +import pygame +import random + +SCREEN = WIDTH, HEIGHT = 288, 512 +display_height = 0.80 * HEIGHT + +pygame.mixer.init() +wing_fx = pygame.mixer.Sound('Sounds/wing.wav') + + +class Grumpy: + def __init__(self, win): + self.win = win + + self.im_list = [] + bird_color = random.choice(['red', 'blue', 'yellow']) + for i in range(1, 4): + img = pygame.image.load(f'Assets/Grumpy/{bird_color}{i}.png') + self.im_list.append(img) + + self.reset() + + def update(self): + # gravity + self.vel += 0.3 + if self.vel >= 8: + self.vel = 8 + if self.rect.bottom <= display_height: + self.rect.y += int(self.vel) + + if self.alive: + + # jump + if pygame.mouse.get_pressed()[0] == 1 and not self.jumped: + wing_fx.play() + self.jumped = True + self.vel = -6 + if pygame.mouse.get_pressed()[0] == 0: + self.jumped = False + + self.flap_counter() + + self.image = pygame.transform.rotate( + self.im_list[self.index], self.vel * -2) + else: + if self.rect.bottom <= display_height: + self.theta -= 2 + self.image = pygame.transform.rotate( + self.im_list[self.index], self.theta) + + self.win.blit(self.image, self.rect) + + def flap_counter(self): + self.counter += 1 + if self.counter > 5: + self.counter = 0 + self.index += 1 + if self.index >= 3: + self.index = 0 + + def draw_flap(self): + self.flap_counter() + if self.flap_pos <= -10 or self.flap_pos > 10: + self.flap_inc *= -1 + self.flap_pos += self.flap_inc + self.rect.y += self.flap_inc + self.rect.x = WIDTH // 2 - 20 + self.image = self.im_list[self.index] + self.win.blit(self.image, self.rect) + + def reset(self): + self.index = 0 + self.image = self.im_list[self.index] + self.rect = self.image.get_rect() + self.rect.x = 60 + self.rect.y = int(display_height) // 2 + self.counter = 0 + self.vel = 0 + self.jumped = False + self.alive = True + self.theta = 0 + self.mid_pos = display_height // 2 + self.flap_pos = 0 + self.flap_inc = 1 + + +class Base: + def __init__(self, win): + self.win = win + + self.image1 = pygame.image.load('Assets/base.png') + self.image2 = self.image1 + self.rect1 = self.image1.get_rect() + self.rect1.x = 0 + self.rect1.y = int(display_height) + self.rect2 = self.image2.get_rect() + self.rect2.x = WIDTH + self.rect2.y = int(display_height) + + def update(self, speed): + self.rect1.x -= speed + self.rect2.x -= speed + + if self.rect1.right <= 0: + self.rect1.x = WIDTH - 5 + if self.rect2.right <= 0: + self.rect2.x = WIDTH - 5 + + self.win.blit(self.image1, self.rect1) + self.win.blit(self.image2, self.rect2) + + +class Pipe(pygame.sprite.Sprite): + def __init__(self, win, image, y, position): + super(Pipe, self).__init__() + + self.win = win + self.image = image + self.rect = self.image.get_rect() + pipe_gap = 100 // 2 + x = WIDTH + + if position == 1: + self.image = pygame.transform.flip(self.image, False, True) + self.rect.bottomleft = (x, y - pipe_gap) + elif position == -1: + self.rect.topleft = (x, y + pipe_gap) + + def update(self, speed): + self.rect.x -= speed + if self.rect.right < 0: + self.kill() + self.win.blit(self.image, self.rect) + + +class Score: + def __init__(self, x, y, win): + self.score_list = [] + for score in range(10): + img = pygame.image.load(f'Assets/Score/{score}.png') + self.score_list.append(img) + self.x = x + self.y = y + + self.win = win + + def update(self, score): + score = str(score) + for index, num in enumerate(score): + self.image = self.score_list[int(num)] + self.rect = self.image.get_rect() + self.rect.topleft = self.x - 15 * len(score) + 30 * index, self.y + self.win.blit(self.image, self.rect) diff --git a/Code-Sleep-Python/Link Shortener/README.md b/Code-Sleep-Python/Link Shortener/README.md new file mode 100644 index 0000000..ea51e58 --- /dev/null +++ b/Code-Sleep-Python/Link Shortener/README.md @@ -0,0 +1,23 @@ + + +

Link Shortener

+ +

+ Python Application | 5 lines of code +
+
+

+

+ +You can create a `Python` program which can be used to shorten a big links. We'll use a shortening web service named `tinyurl`. You need to give your link in the terminal and you'll get the shorten link in the print-screen. + ``` +What the program does? + +- You've to give your big link in the terminal +- Program will use tinyurl server for shortening the link without using any browser +- Shortened link will pass by print() function +``` +### Requirements + +* Python +* Python Libraries: `pyshorteners` diff --git a/Code-Sleep-Python/Link Shortener/source-code.py b/Code-Sleep-Python/Link Shortener/source-code.py new file mode 100644 index 0000000..da3aaf8 --- /dev/null +++ b/Code-Sleep-Python/Link Shortener/source-code.py @@ -0,0 +1,8 @@ +import pyshorteners + +link = input("enter the link:") +shortener = pyshorteners.Shortener() + +x = shortener.tinyurl.short(link) + +print(x) diff --git a/Code-Sleep-Python/connect_four/requirements.txt b/Code-Sleep-Python/connect_four/requirements.txt index a605156..1fbac36 100644 --- a/Code-Sleep-Python/connect_four/requirements.txt +++ b/Code-Sleep-Python/connect_four/requirements.txt @@ -1,2 +1,2 @@ -numpy==1.13.3 +numpy==1.22.0 pygame==1.9.3 diff --git a/Code-Sleep-Python/regression/requirements.txt b/Code-Sleep-Python/regression/requirements.txt index a707d50..bc325ab 100644 --- a/Code-Sleep-Python/regression/requirements.txt +++ b/Code-Sleep-Python/regression/requirements.txt @@ -1,4 +1,4 @@ -numpy==1.13.3 +numpy==1.22.0 pandas==0.21.0 matplotlib==2.1.0 scikit-learn==0.19.1 diff --git a/Code-Sleep-Python/tic-tac-toe/requirements.txt b/Code-Sleep-Python/tic-tac-toe/requirements.txt index 297540b..e2ebf76 100644 --- a/Code-Sleep-Python/tic-tac-toe/requirements.txt +++ b/Code-Sleep-Python/tic-tac-toe/requirements.txt @@ -1 +1 @@ -numpy==1.13.3 \ No newline at end of file +numpy==1.22.0 \ No newline at end of file diff --git a/Code-Sleep-Python/voice assistant/friday.py b/Code-Sleep-Python/voice assistant/friday.py new file mode 100644 index 0000000..dd5ae31 --- /dev/null +++ b/Code-Sleep-Python/voice assistant/friday.py @@ -0,0 +1,92 @@ +import pyttsx3 +import datetime +import speech_recognition as sr +import wikipedia +import webbrowser +import subprocess +import os + +engine = pyttsx3.init('sapi5') +voices = engine.getProperty('voices') +# print(voices[0].id) +engine.setProperty('voice', voices[0].id) + + +def speak(audio): + engine.say(audio) + engine.runAndWait() + + +def wishMe(): + hour = int(datetime.datetime.now().hour) + if hour >= 0 and hour < 12: + speak("good morning sir") + elif hour >= 12 and hour < 18: + speak("good afternoon sir") + else: + speak("Good evening sir") + + speak("I am Friday, your virtual assistant running on python?") + speak("How may I help you?") + +def takeCommand(): + r = sr.Recognizer() + with sr.Microphone() as source: + print("Listening..") + r.pause_threshold = 1 + audio = r.listen(source) + + try: + print("Recognizing...") + query = r.recognize_google(audio, language='en-in') + print(f"User said: {query}\n") + except Exception as e: + print(e) + + print("Please repeat your command..") + return "None" + return query + + +if __name__ == "__main__": + wishMe() +while True: + query = takeCommand().lower() + + if 'wikipedia' in query: + speak('Searching wikipedia...') + query = query.replace("wikipedia", "") + results = wikipedia.summary(query, sentences=1) + speak("According to what i found on wikipedia") + print(results) + speak(results) + elif 'what can you do' in query: + speak("I can search for something in wikipedia,") + speak("open websites, play friends or even open your whatsapp.") + speak("If you are interested to read some amazing blogs say open my blog.") + elif 'who are you' in query: + speak("I am friday, the successor of Jarvis.") + elif 'open youtube' in query: + webbrowser.open("youtube.com") + elif 'open google' in query: + webbrowser.open("google.com") + elif 'open instagram' in query: + webbrowser.open("instagram.com") + elif 'open my blog' in query: + webbrowser.open("codehustler.dev") + elif 'open stackoverflow' in query: + webbrowser.open("stackoverflow.com") + elif 'the time' in query: + strTime = datetime.datetime.now().strftime("%H:%M:%S") + speak(f"Sir, the time is {strTime}") + elif 'open whatsapp' in query: + subprocess.call( + 'C:\\Users\\hp\\AppData\\Local\\WhatsApp\\WhatsApp.exe') + elif 'play friends' in query: + friends_dir = 'G:\\F.R.I.E.N.D.S' + friends = os.listdir(friends_dir) + print(friends) + os.startfile(os.path.join(friends_dir, friends[0])) + elif 'terminate' in query: + speak("Goodbye sir see you soon.") + exit() diff --git a/Code-Sleep-Python/website_status_check/website_status_check.py b/Code-Sleep-Python/website_status_check/website_status_check.py index 8b76429..c6b9718 100644 --- a/Code-Sleep-Python/website_status_check/website_status_check.py +++ b/Code-Sleep-Python/website_status_check/website_status_check.py @@ -14,9 +14,11 @@ def check_url(url): def print_message(code): status_message = { - 100: 'Website is slow to respond, but appears ok.', - 101: 'Server is upgrading to the requested protocol.', - 102: 'Request received, website has yet to respond.', + 100: "Website is slow to respond, but appears ok.", + 101: "Server is upgrading to the requested protocol.", + 102: "Request received, website has yet to respond.", + 103: "Early hints, returns response header preview before the rest " + "of the server's response is ready.", 200: "Website is online.", 201: "The request has succeeded and a new resource has been created.", 202: "The request has been received but not yet acted upon.", diff --git a/Code-Sleep-Python/whisky_classification/requirements.txt b/Code-Sleep-Python/whisky_classification/requirements.txt index 23b2cc0..cf875d5 100644 --- a/Code-Sleep-Python/whisky_classification/requirements.txt +++ b/Code-Sleep-Python/whisky_classification/requirements.txt @@ -1,2 +1,2 @@ -numpy==1.13.3 +numpy==1.22.0 bokeh==0.12.10 \ No newline at end of file diff --git a/README.md b/README.md index a1d08b2..8654bd2 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,7 @@ New to Python? No problem! Take a look at the following resources: - [Python course by Google](https://developers.google.com/edu/python/) (online course) - [Python course by sentdex on YouTube](https://www.youtube.com/playlist?list=PLQVvvaa0QuDe8XSftW-RAxdo6OmaeL85M)(online course) - [Learn Python the Hard Way](https://learnpythonthehardway.org/book/) (book) +- [Learn Python Programming](https://www.scaler.com/topics/python) - [MIT: Introduction to Computer Science and Programming in Python](https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-introduction-to-computer-science-and-programming-in-python-fall-2016/) (open courseware) - [Python for Developers](http://ricardoduarte.github.io/python-for-developers/)(book) - [How to Think Like a Computer Scientist](http://openbookproject.net/thinkcs/python/english3e/)(book) diff --git a/_config.yml b/_config.yml index be854e8..03167a7 100644 --- a/_config.yml +++ b/_config.yml @@ -1,3 +1,3 @@ -theme: jekyll-theme-cayman +theme: jekyll-theme-minimal plugins: - jemoji