Skip to content

Commit a4175ee

Browse files
authored
Add files via upload
1 parent 4eaf111 commit a4175ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+21585
-0
lines changed

Alarm clock/alarm_clock.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Import Required Library
2+
from tkinter import *
3+
import datetime
4+
import time
5+
import winsound
6+
from threading import *
7+
8+
# Create Object
9+
root = Tk()
10+
11+
# Set geometry
12+
root.geometry("400x200")
13+
14+
# Use Threading
15+
def Threading():
16+
t1=Thread(target=alarm)
17+
t1.start()
18+
19+
def alarm():
20+
# Infinite Loop
21+
while True:
22+
# Set Alarm
23+
set_alarm_time = f"{hour.get()}:{minute.get()}:{second.get()}"
24+
25+
# Wait for one seconds
26+
time.sleep(1)
27+
28+
# Get current time
29+
current_time = datetime.datetime.now().strftime("%H:%M:%S")
30+
print(current_time,set_alarm_time)
31+
32+
# Check whether set alarm is equal to current time or not
33+
if current_time == set_alarm_time:
34+
print("Time to Wake up")
35+
# Playing sound
36+
winsound.PlaySound("sound.wav",winsound.SND_ASYNC)
37+
38+
# Add Labels, Frame, Button, Optionmenus
39+
Label(root,text="Alarm Clock",font=("Helvetica 20 bold"),fg="red").pack(pady=10)
40+
Label(root,text="Set Time",font=("Helvetica 15 bold")).pack()
41+
42+
frame = Frame(root)
43+
frame.pack()
44+
45+
hour = StringVar(root)
46+
hours = ('00', '01', '02', '03', '04', '05', '06', '07',
47+
'08', '09', '10', '11', '12', '13', '14', '15',
48+
'16', '17', '18', '19', '20', '21', '22', '23', '24'
49+
)
50+
hour.set(hours[0])
51+
52+
hrs = OptionMenu(frame, hour, *hours)
53+
hrs.pack(side=LEFT)
54+
55+
minute = StringVar(root)
56+
minutes = ('00', '01', '02', '03', '04', '05', '06', '07',
57+
'08', '09', '10', '11', '12', '13', '14', '15',
58+
'16', '17', '18', '19', '20', '21', '22', '23',
59+
'24', '25', '26', '27', '28', '29', '30', '31',
60+
'32', '33', '34', '35', '36', '37', '38', '39',
61+
'40', '41', '42', '43', '44', '45', '46', '47',
62+
'48', '49', '50', '51', '52', '53', '54', '55',
63+
'56', '57', '58', '59', '60')
64+
minute.set(minutes[0])
65+
66+
mins = OptionMenu(frame, minute, *minutes)
67+
mins.pack(side=LEFT)
68+
69+
second = StringVar(root)
70+
seconds = ('00', '01', '02', '03', '04', '05', '06', '07',
71+
'08', '09', '10', '11', '12', '13', '14', '15',
72+
'16', '17', '18', '19', '20', '21', '22', '23',
73+
'24', '25', '26', '27', '28', '29', '30', '31',
74+
'32', '33', '34', '35', '36', '37', '38', '39',
75+
'40', '41', '42', '43', '44', '45', '46', '47',
76+
'48', '49', '50', '51', '52', '53', '54', '55',
77+
'56', '57', '58', '59', '60')
78+
second.set(seconds[0])
79+
80+
secs = OptionMenu(frame, second, *seconds)
81+
secs.pack(side=LEFT)
82+
83+
Button(root,text="Set Alarm",font=("Helvetica 15"),command=Threading).pack(pady=20)
84+
85+
# Execute Tkinter
86+
root.mainloop()
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# All Links from given Webpage
2+
3+
This script retrieves all links from a given Webpage and saves them as a txt file
4+
5+
### Prerequisites
6+
Required Modules
7+
- BeautifulSoup4
8+
- requests
9+
10+
to install:
11+
```
12+
$ pip install -r requirements.txt
13+
```
14+
15+
### How to run the script
16+
``` bash
17+
$ python get_links.py
18+
```
19+
You will then be asked which webpage you would like to analyze.
20+
After that the extracted links will be saved as an array in `myLinks.txt`.
21+
22+
23+
## *Author Name*
24+
[Mitesh](https://github.com/Mitesh2499) & [Michael Mba](https://github.com/mikeysan)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import requests as rq
2+
from bs4 import BeautifulSoup
3+
4+
url = input("Enter Link: ")
5+
if ("https" or "http") in url:
6+
data = rq.get(url)
7+
else:
8+
data = rq.get("https://" + url)
9+
soup = BeautifulSoup(data.text, "html.parser")
10+
links = []
11+
for link in soup.find_all("a"):
12+
links.append(link.get("href"))
13+
14+
# Writing the output to a file (myLinks.txt) instead of to stdout
15+
# You can change 'a' to 'w' to overwrite the file each time
16+
with open("myLinks.txt", 'a') as saved:
17+
print(links[:10], file=saved)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
beautifulsoup4==4.9.2
2+
requests==2.24.0

Ascii_art/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# ascii-art
2+
3+
## Description
4+
This Project will take an image and print out an [ASCII-art](https://en.wikipedia.org/wiki/ASCII_art).
5+
6+
## About this Project
7+
This project uses [opencv](https://www.opencv.org) to process image and [numpy](https://numpy.org) to manipulate arrays. The Image is numerically coded for different threshold regions it comes under and for each coded regions , a symbol is used for printing it out in the stdout.
8+
9+
## Usage
10+
Use the Script [make_art.py](https://github.com/Shiny-Akash/python-mini-projects/blob/ascii-art/projects/asciiart/make_art.py) .
11+
In the command line, Enter
12+
13+
`python3 make_art.py [image_path]`
14+
15+
Replace the `[image_path]` with the image you want to do ascii-art. By default it takes [sample_image.png](https://github.com/Shiny-Akash/python-mini-projects/blob/ascii-art/projects/asciiart/sample_image.png)
16+
17+
## Customization
18+
There are two things you can customize in [make_art.py](https://github.com/Shiny-Akash/python-mini-projects/blob/ascii-art/projects/asciiart/make_art.py).
19+
20+
* `symbols_list`
21+
* `threshold_list`
22+
23+
Modify the threshold list to take **different threshold values** thereby changing the patterns in the printed image.
24+
Modify the symbols list to substitute **different symbols** in the coded patterns.
25+
26+
## Sample
27+
Input Image :
28+
![input_image](sample_image.png)
29+
Output :
30+
![output_image](sample_output.png)

Ascii_art/make_art.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python3
2+
3+
import cv2
4+
import numpy as np
5+
6+
import sys
7+
8+
symbols_list = ["#", "-", "*", ".", "+", "o"]
9+
threshold_list = [0, 50, 100, 150, 200]
10+
11+
def print_out_ascii(array):
12+
"""prints the coded image with symbols"""
13+
14+
for row in array:
15+
for e in row:
16+
# select symbol based on the type of coding
17+
print(symbols_list[int(e) % len(symbols_list)], end="")
18+
print()
19+
20+
21+
def img_to_ascii(image):
22+
"""returns the numeric coded image"""
23+
24+
# resizing parameters
25+
# adjust these parameters if the output doesn't fit to the screen
26+
height, width = image.shape
27+
new_width = int(width / 20)
28+
new_height = int(height / 40)
29+
30+
# resize image to fit the printing screen
31+
resized_image = cv2.resize(image, (new_width, new_height),)
32+
33+
thresh_image = np.zeros(resized_image.shape)
34+
35+
for i, threshold in enumerate(threshold_list):
36+
# assign corresponding values according to the index of threshold applied
37+
thresh_image[resized_image > threshold] = i
38+
return thresh_image
39+
40+
41+
if __name__ == "__main__":
42+
43+
if len(sys.argv) < 2:
44+
print("Image Path not specified : Using sample_image.png\n")
45+
image_path = "sample_image.png" # default image path
46+
47+
if len(sys.argv) == 2:
48+
print("Using {} as Image Path\n".format(sys.argv[1]))
49+
image_path = sys.argv[1]
50+
51+
image = cv2.imread(image_path, 0) # read image
52+
53+
ascii_art = img_to_ascii(image)
54+
print_out_ascii(ascii_art)

Ascii_art/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
opencv-python==4.3.0.36
2+
numpy==1.19.1

Ascii_art/sample_image.png

48.6 KB
Loading

Ascii_art/sample_output.png

6.31 KB
Loading

AudioBook/Audio-book.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#Importing Libraries
2+
#Importing Google Text to Speech library
3+
from gtts import gTTS
4+
5+
#Importing PDF reader PyPDF2
6+
import PyPDF2
7+
8+
#Open file Path
9+
pdf_File = open('name.pdf', 'rb')
10+
11+
#Create PDF Reader Object
12+
pdf_Reader = PyPDF2.PdfFileReader(pdf_File)
13+
count = pdf_Reader.numPages # counts number of pages in pdf
14+
textList = []
15+
16+
#Extracting text data from each page of the pdf file
17+
for i in range(count):
18+
try:
19+
page = pdf_Reader.getPage(i)
20+
textList.append(page.extractText())
21+
except:
22+
pass
23+
24+
#Converting multiline text to single line text
25+
textString = " ".join(textList)
26+
27+
print(textString)
28+
29+
#Set language to english (en)
30+
language = 'en'
31+
32+
#Call GTTS
33+
myAudio = gTTS(text=textString, lang=language, slow=False)
34+
35+
#Save as mp3 file
36+
myAudio.save("Audio.mp3")

0 commit comments

Comments
 (0)