mirror of
https://github.com/metafy-social/python-scripts.git
synced 2024-11-23 20:11:10 +00:00
Merge branch 'metafy-social:master' into master
This commit is contained in:
commit
640a9befc2
164
README.md
164
README.md
|
@ -81,27 +81,13 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/muratonuryildirim">
|
||||
<img src="https://avatars.githubusercontent.com/u/77264793?v=4" width="100;" alt="muratonuryildirim"/>
|
||||
<a href="https://github.com/SiddheshKukade">
|
||||
<img src="https://avatars.githubusercontent.com/u/65951872?v=4" width="100;" alt="SiddheshKukade"/>
|
||||
<br />
|
||||
<sub><b>Murat Onur Yildirim</b></sub>
|
||||
<sub><b>Siddhesh Bhupendra Kuakde</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Ayudh-65">
|
||||
<img src="https://avatars.githubusercontent.com/u/68161774?v=4" width="100;" alt="Ayudh-65"/>
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/vallabhiaf">
|
||||
<img src="https://avatars.githubusercontent.com/u/10003129?v=4" width="100;" alt="vallabhiaf"/>
|
||||
<br />
|
||||
<sub><b>Vallabh Chugh</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/rahulkarda">
|
||||
<img src="https://avatars.githubusercontent.com/u/76204863?v=4" width="100;" alt="rahulkarda"/>
|
||||
|
@ -116,12 +102,41 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<sub><b>Noor Ahmed</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/muratonuryildirim">
|
||||
<img src="https://avatars.githubusercontent.com/u/77264793?v=4" width="100;" alt="muratonuryildirim"/>
|
||||
<br />
|
||||
<sub><b>Murat Onur Yildirim</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Ayudh-65">
|
||||
<img src="https://avatars.githubusercontent.com/u/68161774?v=4" width="100;" alt="Ayudh-65"/>
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/vallabhiaf">
|
||||
<img src="https://avatars.githubusercontent.com/u/10003129?v=4" width="100;" alt="vallabhiaf"/>
|
||||
<br />
|
||||
<sub><b>Vallabh Chugh</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Abbhiishek">
|
||||
<img src="https://avatars.githubusercontent.com/u/86338762?v=4" width="100;" alt="Abbhiishek"/>
|
||||
<br />
|
||||
<sub><b>Abhishek Kushwaha</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Khushi260">
|
||||
<img src="https://avatars.githubusercontent.com/u/94845508?v=4" width="100;" alt="Khushi260"/>
|
||||
<br />
|
||||
<sub><b>Khushi Jha</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/yunghog">
|
||||
|
@ -129,8 +144,7 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>YUNGH OG</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Farhan-2222">
|
||||
<img src="https://avatars.githubusercontent.com/u/87274221?v=4" width="100;" alt="Farhan-2222"/>
|
||||
|
@ -152,26 +166,12 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<sub><b>Raihan Khan</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/SiddheshKukade">
|
||||
<img src="https://avatars.githubusercontent.com/u/65951872?v=4" width="100;" alt="SiddheshKukade"/>
|
||||
<br />
|
||||
<sub><b>Siddhesh Bhupendra Kuakde</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/ArshErgon">
|
||||
<img src="https://avatars.githubusercontent.com/u/40994679?v=4" width="100;" alt="ArshErgon"/>
|
||||
<br />
|
||||
<sub><b>Mohd Arsh Ali </b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Khushi260">
|
||||
<img src="https://avatars.githubusercontent.com/u/94845508?v=4" width="100;" alt="Khushi260"/>
|
||||
<br />
|
||||
<sub><b>Khushi Jha</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
|
@ -281,6 +281,13 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/srishti011">
|
||||
<img src="https://avatars.githubusercontent.com/u/48403800?v=4" width="100;" alt="srishti011"/>
|
||||
<br />
|
||||
<sub><b>Srishti</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Tiagupt03">
|
||||
<img src="https://avatars.githubusercontent.com/u/98590820?v=4" width="100;" alt="Tiagupt03"/>
|
||||
|
@ -294,6 +301,14 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Avyay Jain</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/devtayade">
|
||||
<img src="https://avatars.githubusercontent.com/u/84332795?v=4" width="100;" alt="devtayade"/>
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/drk1rd">
|
||||
|
@ -301,8 +316,7 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Drk1rd</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/lordvader501">
|
||||
<img src="https://avatars.githubusercontent.com/u/60027612?v=4" width="100;" alt="lordvader501"/>
|
||||
|
@ -330,6 +344,14 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Srinjoy Pati</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/personal-use1">
|
||||
<img src="https://avatars.githubusercontent.com/u/115635715?v=4" width="100;" alt="personal-use1"/>
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Shradha-Suman">
|
||||
|
@ -344,8 +366,7 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Nishant Pacharne</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/thegeekyb0y">
|
||||
<img src="https://avatars.githubusercontent.com/u/84658112?v=4" width="100;" alt="thegeekyb0y"/>
|
||||
|
@ -366,7 +387,8 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Hemant</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/MayuriKolhe-2003">
|
||||
<img src="https://avatars.githubusercontent.com/u/77161474?v=4" width="100;" alt="MayuriKolhe-2003"/>
|
||||
|
@ -387,8 +409,7 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Parinthapat P.</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/iamrahul8">
|
||||
<img src="https://avatars.githubusercontent.com/u/72541381?v=4" width="100;" alt="iamrahul8"/>
|
||||
|
@ -409,7 +430,8 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Sayan Roy</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Tanya-1109">
|
||||
<img src="https://avatars.githubusercontent.com/u/107848751?v=4" width="100;" alt="Tanya-1109"/>
|
||||
|
@ -430,8 +452,7 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Ambush</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/aswin2108">
|
||||
<img src="https://avatars.githubusercontent.com/u/72661784?v=4" width="100;" alt="aswin2108"/>
|
||||
|
@ -452,7 +473,8 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Sauraj</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/accodes21">
|
||||
<img src="https://avatars.githubusercontent.com/u/101868279?v=4" width="100;" alt="accodes21"/>
|
||||
|
@ -473,8 +495,7 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Akash Jain</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Rancho2002">
|
||||
<img src="https://avatars.githubusercontent.com/u/92109154?v=4" width="100;" alt="Rancho2002"/>
|
||||
|
@ -482,13 +503,21 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<sub><b>Arijit Ghosh</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Yaswanth820">
|
||||
<img src="https://avatars.githubusercontent.com/u/55750562?v=4" width="100;" alt="Yaswanth820"/>
|
||||
<br />
|
||||
<sub><b>Balaji Yaswanth Vankala</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Danuragtiwari">
|
||||
<img src="https://avatars.githubusercontent.com/u/86867000?v=4" width="100;" alt="Danuragtiwari"/>
|
||||
<br />
|
||||
<sub><b>ANURAG TIWARI</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/dishant-yadav">
|
||||
<img src="https://avatars.githubusercontent.com/u/97543666?v=4" width="100;" alt="dishant-yadav"/>
|
||||
|
@ -516,8 +545,7 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>KUMAR SANTOSH</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Manice18">
|
||||
<img src="https://avatars.githubusercontent.com/u/91601706?v=4" width="100;" alt="Manice18"/>
|
||||
|
@ -531,7 +559,8 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/LEO1612D">
|
||||
<img src="https://avatars.githubusercontent.com/u/46849277?v=4" width="100;" alt="LEO1612D"/>
|
||||
|
@ -559,8 +588,7 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Riya Jaiswal</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/sarthakroy2002">
|
||||
<img src="https://avatars.githubusercontent.com/u/47187468?v=4" width="100;" alt="sarthakroy2002"/>
|
||||
|
@ -574,7 +602,8 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Shreejan Dolai</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/Tejaswi-Kumar">
|
||||
<img src="https://avatars.githubusercontent.com/u/67323842?v=4" width="100;" alt="Tejaswi-Kumar"/>
|
||||
|
@ -602,8 +631,7 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Arpit Bhardwaj</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/artemis-i-guess">
|
||||
<img src="https://avatars.githubusercontent.com/u/65388018?v=4" width="100;" alt="artemis-i-guess"/>
|
||||
|
@ -617,7 +645,8 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/codeswithroh">
|
||||
<img src="https://avatars.githubusercontent.com/u/77570394?v=4" width="100;" alt="codeswithroh"/>
|
||||
|
@ -625,13 +654,6 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<sub><b>Rohit Purkait</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/devtayade">
|
||||
<img src="https://avatars.githubusercontent.com/u/84332795?v=4" width="100;" alt="devtayade"/>
|
||||
<br />
|
||||
<sub><b>Null</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/yashbrid03">
|
||||
<img src="https://avatars.githubusercontent.com/u/65955929?v=4" width="100;" alt="yashbrid03"/>
|
||||
|
@ -645,8 +667,7 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Michele Mazza</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/mer747">
|
||||
<img src="https://avatars.githubusercontent.com/u/84189502?v=4" width="100;" alt="mer747"/>
|
||||
|
@ -661,20 +682,14 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<sub><b>Mubeen Ahmad</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/nabroleonx">
|
||||
<img src="https://avatars.githubusercontent.com/u/84567489?v=4" width="100;" alt="nabroleonx"/>
|
||||
<br />
|
||||
<sub><b>Abel Ayalew</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/neocollege">
|
||||
<img src="https://avatars.githubusercontent.com/u/86466839?v=4" width="100;" alt="neocollege"/>
|
||||
<br />
|
||||
<sub><b>Prathamesh Nayak</b></sub>
|
||||
</a>
|
||||
</td>
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<a href="https://github.com/smit-sms">
|
||||
<img src="https://avatars.githubusercontent.com/u/52400400?v=4" width="100;" alt="smit-sms"/>
|
||||
|
@ -688,8 +703,7 @@ Thanks a lot for spending your time helping! Keep rocking 🍻
|
|||
<br />
|
||||
<sub><b>Sameer Sahu</b></sub>
|
||||
</a>
|
||||
</td></tr>
|
||||
<tr>
|
||||
</td>
|
||||
<td align="center">
|
||||
<a href="https://github.com/shatanikmahanty">
|
||||
<img src="https://avatars.githubusercontent.com/u/67138059?v=4" width="100;" alt="shatanikmahanty"/>
|
||||
|
|
48
scripts/Calculate_your_age_script/script.py
Normal file
48
scripts/Calculate_your_age_script/script.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
import time
|
||||
from calendar import isleap
|
||||
|
||||
# judge the leap year
|
||||
def judge_leap_year(year):
|
||||
if isleap(year):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
# returns the number of days in each month
|
||||
def month_days(month, leap_year):
|
||||
if month in [1, 3, 5, 7, 8, 10, 12]:
|
||||
return 31
|
||||
elif month in [4, 6, 9, 11]:
|
||||
return 30
|
||||
elif month == 2 and leap_year:
|
||||
return 29
|
||||
elif month == 2 and (not leap_year):
|
||||
return 28
|
||||
|
||||
|
||||
name = input("input your name: ")
|
||||
age = input("input your age: ")
|
||||
localtime = time.localtime(time.time())
|
||||
|
||||
year = int(age)
|
||||
month = year * 12 + localtime.tm_mon
|
||||
day = 0
|
||||
|
||||
begin_year = int(localtime.tm_year) - year
|
||||
end_year = begin_year + year
|
||||
|
||||
# calculate the days
|
||||
for y in range(begin_year, end_year):
|
||||
if (judge_leap_year(y)):
|
||||
day = day + 366
|
||||
else:
|
||||
day = day + 365
|
||||
|
||||
leap_year = judge_leap_year(localtime.tm_year)
|
||||
for m in range(1, localtime.tm_mon):
|
||||
day = day + month_days(m, leap_year)
|
||||
|
||||
day = day + localtime.tm_mday
|
||||
print("%s's age is %d years or " % (name, year), end="")
|
||||
print("%d months or %d days" % (month, day))
|
6
scripts/Copy to clipboard/README.md
Normal file
6
scripts/Copy to clipboard/README.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Copy to Clipboard
|
||||
A tool that will help you to copy the contents of a file having any size without opening that file
|
||||
## Usage/Examples
|
||||
```sh
|
||||
$ clipboard.py <fileName>
|
||||
```
|
29
scripts/Copy to clipboard/clipboard.py
Normal file
29
scripts/Copy to clipboard/clipboard.py
Normal file
|
@ -0,0 +1,29 @@
|
|||
import os
|
||||
import sys
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
# Seeing if the file exists
|
||||
if os.path.exists(sys.argv[1]):
|
||||
# Open Only if the file exists on the computer
|
||||
f = open(sys.argv[1], "r")
|
||||
# Storing the Content of the file in the f_contents variable
|
||||
f_contents = f.read()
|
||||
# closing the opened file
|
||||
f.close()
|
||||
else:
|
||||
# If the file Doesn't Exists
|
||||
print("File Not found : copy2clip <file_name>")
|
||||
exit(1)
|
||||
# Storing the current OS version
|
||||
whatos = platform.system()
|
||||
# If Darwin or Ubuntu
|
||||
if whatos == "Darwin":
|
||||
subprocess.run("pbcopy", universal_newlines=True, input=f_contents)
|
||||
print("success: copied to clipboard")
|
||||
# If Windows
|
||||
elif whatos == "Windows":
|
||||
subprocess.run("clip", universal_newlines=True, input=f_contents)
|
||||
print("success: copied to clipboard")
|
||||
else:
|
||||
print("failed: clipboard not supported")
|
16
scripts/Extract_TEXT_FROM_IMAGE/README.md
Normal file
16
scripts/Extract_TEXT_FROM_IMAGE/README.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
# Extract text from image
|
||||
|
||||
This script extracts text from an image using the EasyOCR library.
|
||||
It can support multiple languages.
|
||||
|
||||
## Usage
|
||||
|
||||
1. Create a virtual environment
|
||||
2. Install the requirements - `pip install -r requirements.txt`
|
||||
3. Run the script - `python main.py`
|
||||
|
||||
## Output
|
||||
|
||||
Output will be printed to console.
|
||||
|
||||
Happy coding!!
|
15
scripts/Extract_TEXT_FROM_IMAGE/main.py
Normal file
15
scripts/Extract_TEXT_FROM_IMAGE/main.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
import easyocr
|
||||
|
||||
gpu = False # if you want to use GPU, set gpu=True
|
||||
languages = ['en'] # refer https://www.jaided.ai/easyocr/ for supporting languages
|
||||
|
||||
reader = easyocr.Reader(languages, gpu=gpu)
|
||||
|
||||
IMG_PATH = 'test1.png'
|
||||
result = reader.readtext(IMG_PATH)
|
||||
|
||||
text = ''
|
||||
for tup in result:
|
||||
text += tup[1]
|
||||
|
||||
print(text)
|
1
scripts/Extract_TEXT_FROM_IMAGE/requirements.txt
Normal file
1
scripts/Extract_TEXT_FROM_IMAGE/requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
easyocr==1.6.2
|
BIN
scripts/Extract_TEXT_FROM_IMAGE/test1.png
Normal file
BIN
scripts/Extract_TEXT_FROM_IMAGE/test1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 107 KiB |
1291
scripts/Loan Prediction Model/Loan Prediction Model .ipynb
Normal file
1291
scripts/Loan Prediction Model/Loan Prediction Model .ipynb
Normal file
File diff suppressed because one or more lines are too long
22
scripts/Loan Prediction Model/Readme.md
Normal file
22
scripts/Loan Prediction Model/Readme.md
Normal file
|
@ -0,0 +1,22 @@
|
|||
## Loan Prediction Model
|
||||
|
||||
|
||||
The goal of this project is that from the data collected on the loan’s applicants, preprocess the data and predict based on the information who will be able to receive the loan or not.
|
||||
|
||||
|
||||
### In the Dataset we find the following features:
|
||||
|
||||
1. Loan ID, the identifier code of each applicant.
|
||||
2. Gender, Male or Female for each applicant.
|
||||
3. Married, the maritage state.
|
||||
4. Dependents, how many dependents does the applicant have?
|
||||
5. Education, the level of education, graduate or non graduate
|
||||
6. Self Employed, Yes or No in the case
|
||||
7. Applicant Income
|
||||
8. Coapplicant Income
|
||||
9. Loan Amount
|
||||
10. Loan Amount Term
|
||||
11. Credit History, just Yes or No in the case
|
||||
12. Property Area, urban, semiurban or rural area of the applicant’s property
|
||||
|
||||
Loan Status, Yes or No ( The independent variable represents the class)
|
22
scripts/Lyrics Scraper/LyricsScraper.py
Normal file
22
scripts/Lyrics Scraper/LyricsScraper.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
|
||||
def get_lyrics(artist, song):
|
||||
song_url = 'http://www.azlyrics.com/lyrics/' + artist + '/' + song + '.html'
|
||||
|
||||
response = requests.get(song_url)
|
||||
|
||||
soup = BeautifulSoup(response.content, 'html.parser')
|
||||
try:
|
||||
lyrics = soup.find(
|
||||
'div', class_='col-xs-12 col-lg-8 text-center').find_all('div')[5].text
|
||||
print(lyrics)
|
||||
except AttributeError:
|
||||
print("Please make sure you have entered the correct name(i.e. Don't add spaces between words)!")
|
||||
|
||||
|
||||
artist = input(
|
||||
"Enter the name of the artist/band: ").strip().lower().replace(' ', '')
|
||||
song = input("Enter the name of the song: ").strip().lower().replace(' ', '')
|
||||
get_lyrics(artist, song)
|
9
scripts/Lyrics Scraper/README.md
Normal file
9
scripts/Lyrics Scraper/README.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Lyrics scraper
|
||||
|
||||
This simple script scrapes [Azlyrics](http://www.azlyrics.com) given the artist and the song name.
|
||||
|
||||
## Usage
|
||||
|
||||
It's pretty straight-forward, just install the requiremnts and run it.
|
||||
|
||||
`pip install -r requirements.txt`
|
2
scripts/Lyrics Scraper/requirements.txt
Normal file
2
scripts/Lyrics Scraper/requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
bs4
|
||||
requests
|
13
scripts/Music Player/README.md
Normal file
13
scripts/Music Player/README.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Music Player GUI
|
||||
|
||||
![Screenshot (465)](https://user-images.githubusercontent.com/48403800/195563802-fdc224c3-8325-4e1b-b768-2d85e44a3666.png)
|
||||
|
||||
This is a GUI framework where two GUI libraries are used:
|
||||
|
||||
- Pygame
|
||||
- Tkinter
|
||||
|
||||
It has functions such as play, stop, pause and resume in order to control the music player.
|
||||
|
||||
To create a music player with Python, we will be using the **Pygame** sound component and _askdirectory()_ method of Tkinter
|
||||
|
45
scripts/Music Player/music-player.py
Normal file
45
scripts/Music Player/music-player.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
import pygame
|
||||
import tkinter as tkr
|
||||
from tkinter.filedialog import askdirectory
|
||||
import os
|
||||
|
||||
music_player = tkr.Tk()
|
||||
music_player.title("My Music Player")
|
||||
music_player.geometry("450x350")
|
||||
directory = askdirectory()
|
||||
os.chdir(directory)
|
||||
song_list = os.listdir()
|
||||
|
||||
play_list = tkr.Listbox(music_player, font="Helvetica 12 bold", bg='yellow', selectmode=tkr.SINGLE)
|
||||
for item in song_list:
|
||||
pos = 0
|
||||
play_list.insert(pos, item)
|
||||
pos += 1
|
||||
pygame.init()
|
||||
pygame.mixer.init()
|
||||
|
||||
def play():
|
||||
pygame.mixer.music.load(play_list.get(tkr.ACTIVE))
|
||||
var.set(play_list.get(tkr.ACTIVE))
|
||||
pygame.mixer.music.play()
|
||||
def stop():
|
||||
pygame.mixer.music.stop()
|
||||
def pause():
|
||||
pygame.mixer.music.pause()
|
||||
def unpause():
|
||||
pygame.mixer.music.unpause()
|
||||
Button1 = tkr.Button(music_player, width=5, height=3, font="Helvetica 12 bold", text="PLAY", command=play, bg="blue", fg="white")
|
||||
Button2 = tkr.Button(music_player, width=5, height=3, font="Helvetica 12 bold", text="STOP", command=stop, bg="red", fg="white")
|
||||
Button3 = tkr.Button(music_player, width=5, height=3, font="Helvetica 12 bold", text="PAUSE", command=pause, bg="purple", fg="white")
|
||||
Button4 = tkr.Button(music_player, width=5, height=3, font="Helvetica 12 bold", text="UNPAUSE", command=unpause, bg="orange", fg="white")
|
||||
|
||||
var = tkr.StringVar()
|
||||
song_title = tkr.Label(music_player, font="Helvetica 12 bold", textvariable=var)
|
||||
|
||||
song_title.pack()
|
||||
Button1.pack(fill="x")
|
||||
Button2.pack(fill="x")
|
||||
Button3.pack(fill="x")
|
||||
Button4.pack(fill="x")
|
||||
play_list.pack(fill="both", expand="yes")
|
||||
music_player.mainloop()
|
2
scripts/Music Player/requirements.txt
Normal file
2
scripts/Music Player/requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
pygame
|
||||
tkinter
|
5
scripts/Quotes Fetch/readme.md
Normal file
5
scripts/Quotes Fetch/readme.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
## A program to fetch random quote or term related quote from internet
|
||||
|
||||
use following command to search quote related to a specific term or phrase
|
||||
|
||||
python scrape.py -q your_search_term -r yes
|
35
scripts/Quotes Fetch/scrape.py
Normal file
35
scripts/Quotes Fetch/scrape.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
#import section
|
||||
import requests
|
||||
from bs4 import BeautifulSoup as bs
|
||||
import argparse
|
||||
from random import choice
|
||||
|
||||
# parser object to read cli content
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-q", help="for search term")
|
||||
parser.add_argument("-r", help="if you want one random quote")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
search_term = args.q
|
||||
page = 1
|
||||
# URl definition
|
||||
url = f"https://www.brainyquote.com/search_results?q={search_term}&pg={page}"
|
||||
|
||||
# main program
|
||||
r = requests.get(url)
|
||||
soup = bs(r.content, "html.parser")
|
||||
anchor1 = soup.find_all('a', {"class": "b-qt"})
|
||||
anchor2 = soup.find_all('a', {"class": "bq-aut"})
|
||||
|
||||
|
||||
if args.r != None:
|
||||
quote = choice(
|
||||
[f"{quote.text.strip()} - {author.text.strip()}" for quote, author in zip(anchor1, anchor2)])
|
||||
print(quote)
|
||||
else:
|
||||
for i, (quote, author) in enumerate(zip(anchor1, anchor2)):
|
||||
quote = quote.find('div').text.strip()
|
||||
author = author.text.strip()
|
||||
print(f"[{i}] : {quote} - {author}")
|
|
@ -1,11 +1,7 @@
|
|||
import random
|
||||
import time
|
||||
import sys
|
||||
# print(""" ──────────────────██
|
||||
# ▄───▄▀█▄▄▄▄
|
||||
# ─ ▄▀─█▄▄
|
||||
# ▄▄▄▀───▀▄
|
||||
# ▀────────▀▀ """)
|
||||
|
||||
|
||||
def start():
|
||||
# story generated
|
||||
|
@ -105,7 +101,7 @@ def level2():
|
|||
print('You are running far away from the robots')
|
||||
|
||||
time.sleep(2)
|
||||
print(""" ──────────────────██
|
||||
print(""" ──────────────────────██
|
||||
▄───▄▀█▄▄▄▄
|
||||
─ ▄▀─█▄▄
|
||||
▄▄▄▀───▀▄
|
||||
|
@ -188,59 +184,160 @@ def level2():
|
|||
´´´´´¶¶¶¶¶¶¶¶¶¶¶¶´
|
||||
´´´´´´´¶¶¶¶¶¶¶¶
|
||||
""")
|
||||
# question_one = ''
|
||||
# while question_one != 'run away' and question_one != 'shoot robot in head':
|
||||
items = ''
|
||||
while items != 'tank' and items != 'bomb' and items != 'mech suit':
|
||||
items = input("which item do you choose - the mech suit, tank or bomb : ")
|
||||
|
||||
items = input("which item do you choose - the mech suit, tank or bomb : ")
|
||||
|
||||
if (items == 'tank'):
|
||||
time.sleep(3)
|
||||
print('oh no the cyborg has ripped through the tank')
|
||||
time.sleep(3)
|
||||
print('you are running away to find safety')
|
||||
time.sleep(3)
|
||||
print('but the cyborg has seen you and captured you')
|
||||
|
||||
elif (items == 'bomb'):
|
||||
time.sleep(3)
|
||||
print('you throw the bomb and it exlodes')
|
||||
time.sleep(3)
|
||||
print('but it doesnt even lay a scratch on him')
|
||||
time.sleep(3)
|
||||
print('because he is made from vibranium')
|
||||
time.sleep(3)
|
||||
print('you are instantly captured now')
|
||||
|
||||
elif (items == "mech suit"):
|
||||
time.sleep(3)
|
||||
print('you are now in the mech suit')
|
||||
time.sleep(3)
|
||||
print('the cyborg is running towards you')
|
||||
time.sleep(3)
|
||||
print('this suit is highly advanced and gives you a ton of diffrent options')
|
||||
|
||||
time.sleep(3)
|
||||
select_option = input("what would you like to use: rocket fist, missile, body slam: ")
|
||||
|
||||
if (select_option == "rocket fist"):
|
||||
if (items == 'tank'):
|
||||
time.sleep(3)
|
||||
print('good the cyborg is extremely disorientated')
|
||||
print('oh no the cyborg has ripped through the tank')
|
||||
time.sleep(3)
|
||||
combat_moves = input("do you want to throw a right hook or head butt: ")
|
||||
if (combat_moves == 'right hook'):
|
||||
print('you are running away to find safety')
|
||||
time.sleep(3)
|
||||
print('but the cyborg has seen you and captured you')
|
||||
|
||||
elif (items == 'bomb'):
|
||||
time.sleep(3)
|
||||
print('you throw the bomb and it exlodes')
|
||||
time.sleep(3)
|
||||
print('but it doesnt even lay a scratch on him')
|
||||
time.sleep(3)
|
||||
print('because he is made from vibranium')
|
||||
time.sleep(3)
|
||||
print('you are instantly captured now')
|
||||
|
||||
elif (items == "mech suit"):
|
||||
time.sleep(3)
|
||||
print('you are now in the mech suit')
|
||||
time.sleep(3)
|
||||
print('the cyborg is running towards you')
|
||||
time.sleep(3)
|
||||
print('this suit is highly advanced and gives you a ton of diffrent options')
|
||||
suit_options()
|
||||
# question_one = ''
|
||||
# while question_one != 'run away' and question_one != 'shoot robot in head':
|
||||
def combat_option():
|
||||
combat_moves = ''
|
||||
while combat_moves != 'right hook' and combat_moves != 'head butt':
|
||||
time.sleep(3)
|
||||
combat_moves = input("do you want to throw a right hook or head butt: ")
|
||||
if (combat_moves == 'right hook'):
|
||||
time.sleep(3)
|
||||
print('wow your right hook to the cyborg was so DEVASTATING that it has killed him')
|
||||
level3()
|
||||
elif (combat_moves == 'head butt'):
|
||||
time.sleep(3)
|
||||
print('incredible your head butt has KNOCKED OUT the cyborg')
|
||||
level3()
|
||||
|
||||
def suit_options():
|
||||
time.sleep(3)
|
||||
select_option = ''
|
||||
while select_option != 'rocket fist' and select_option != 'missile' and select_option != 'body slam':
|
||||
select_option = input("what would you like to use: rocket fist, missile, body slam: ")
|
||||
|
||||
if (select_option == "rocket fist"):
|
||||
time.sleep(3)
|
||||
print('wow your right hook to the cyborg was so DEVASTATING that it has killed him')
|
||||
elif (combat_moves == 'head butt'):
|
||||
print('good the cyborg is extremely disorientated')
|
||||
combat_option()
|
||||
# def combat_option():
|
||||
# combat_moves = ''
|
||||
# while combat_moves != 'right hook' and combat_moves != 'head butt':
|
||||
# time.sleep(3)
|
||||
# combat_moves = input("do you want to throw a right hook or head butt: ")
|
||||
# if (combat_moves == 'right hook'):
|
||||
# time.sleep(3)
|
||||
# print('wow your right hook to the cyborg was so DEVASTATING that it has killed him')
|
||||
# level3()
|
||||
# elif (combat_moves == 'head butt'):
|
||||
# time.sleep(3)
|
||||
# print('incredible your head butt has KNOCKED OUT the cyborg')
|
||||
# level3()
|
||||
|
||||
elif (select_option == 'missile'):
|
||||
time.sleep(3)
|
||||
print('incredible your head butt has KNOCKED OUT the cyborg')
|
||||
elif (select_option == 'missile'):
|
||||
print('oh no the cyborg is made from vibranium')
|
||||
time.sleep(3)
|
||||
print('the cyborg punches you and takes you back to the robots')
|
||||
elif (select_option == 'body slam'):
|
||||
time.sleep(3)
|
||||
print('the cyborg has been knocked unconsious good job')
|
||||
time.sleep(3)
|
||||
print('u have enough time to run')
|
||||
level3()
|
||||
|
||||
def level3():
|
||||
time.sleep(3)
|
||||
print('after that battle you are completely drained and are trying to find safety')
|
||||
time.sleep(3)
|
||||
print('after walking for hours you come across a strange looking object')
|
||||
time.sleep(3)
|
||||
print('the strange looking object looks like a computer from the past')
|
||||
time.sleep(4)
|
||||
print("""
|
||||
▐▓█▀▀▀▀▀▀▀▀▀█▓▌░▄▄▄▄▄░
|
||||
▐▓█░░▀░░▀▄░░█▓▌░█▄▄▄█░
|
||||
▐▓█░░▄░░▄▀░░█▓▌░█▄▄▄█░
|
||||
▐▓█▄▄▄▄▄▄▄▄▄█▓▌░█████░
|
||||
░░░░▄▄███▄▄░░░░░█████░
|
||||
|
||||
""")
|
||||
time.sleep(3)
|
||||
print('there is a video recording on it')
|
||||
# question_one = ''
|
||||
# while question_one != 'run away' and question_one != 'shoot robot in head':
|
||||
message = ''
|
||||
while message != 'yes' and message != 'no':
|
||||
message = input('Do you want to play the recording: ')
|
||||
if message == 'yes':
|
||||
time.sleep(2)
|
||||
print('...')
|
||||
time.sleep(2)
|
||||
print('..')
|
||||
time.sleep(2)
|
||||
print('.')
|
||||
time.sleep(3)
|
||||
print('oh no the cyborg is made from vibranium')
|
||||
print('Computer: We have found a way to end the war')
|
||||
time.sleep(3)
|
||||
print('the cyborg punches you and takes you back to the robots')
|
||||
elif (select_option == 'body slam'):
|
||||
print('We have ...')
|
||||
time.sleep(5)
|
||||
print("Computer: We have created an algorithm which can search and terminate all AI organisms")
|
||||
time.sleep(2)
|
||||
print('Computer: OH NO')
|
||||
time.sleep(3)
|
||||
print('the cyborg has been knocked unconsious good job')
|
||||
print('Computer: the machines have invaded our base')
|
||||
time.sleep(3)
|
||||
print('u have enough time to run')
|
||||
print("/@)|¬!}{")
|
||||
algorithm()
|
||||
|
||||
def algorithm():
|
||||
time.sleep(3)
|
||||
initiate = ''
|
||||
while initiate != 'start' and initiate != 'terminate':
|
||||
initiate = input('If you wish to initiate this algorithm please type start or if you wish to terminate the algorithm please type terminate: ')
|
||||
if (initiate == 'start'):
|
||||
time.sleep(3)
|
||||
print('....')
|
||||
time.sleep(3)
|
||||
print('beep')
|
||||
time.sleep(3)
|
||||
print('boop')
|
||||
time.sleep(3)
|
||||
print('boop')
|
||||
time.sleep(3)
|
||||
print('beep')
|
||||
time.sleep(3)
|
||||
print('Congratulations you have sucessfully killed all of the robots in this timeline !!!!!!')
|
||||
|
||||
|
||||
elif (initiate == 'terminate'):
|
||||
time.sleep(3)
|
||||
print('WTF !!!!')
|
||||
|
||||
|
||||
|
||||
# option to play again at completion of game
|
||||
play_again = "yes"
|
||||
|
||||
|
|
49
scripts/Voice_Assited_Musicplayer/.gitignore
vendored
Normal file
49
scripts/Voice_Assited_Musicplayer/.gitignore
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
bin/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
.tox/
|
||||
.coverage
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
||||
# Mr Developer
|
||||
.mr.developer.cfg
|
||||
.project
|
||||
.pydevproject
|
||||
|
||||
# Rope
|
||||
.ropeproject
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
*.pot
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
33
scripts/Voice_Assited_Musicplayer/README.md
Normal file
33
scripts/Voice_Assited_Musicplayer/README.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Voice_assisted_musicplayer
|
||||
This project contains Ai powered voice activated music player system.
|
||||
The system supports mp3,wav and mpeg audio files.
|
||||
It can also play songs according to yor emotion(files need to be stored in voice_assisted_musicplayer/Songs/[-] **folder name according to your choice**)
|
||||
It can also load music files form other directories.
|
||||
|
||||
To run the program execute the assistant.py file and say the desired song according to your mood
|
||||
# preview
|
||||
![image](https://user-images.githubusercontent.com/115635715/195788102-1906c8b2-edd7-456b-9a10-7130bfb19704.png)
|
||||
|
||||
![image](https://user-images.githubusercontent.com/115635715/195788334-144aab6a-bb67-42a1-a427-63ceef34a8fe.png)
|
||||
|
||||
|
||||
## Features of the music player:
|
||||
-backward button<br>
|
||||
-forward button<br>
|
||||
-pause/play button<br>
|
||||
-progress bar<br>
|
||||
-volume button<br>
|
||||
-delete button<br>
|
||||
-load file button<br>
|
||||
|
||||
|
||||
## Requirements:<br>
|
||||
pyttsx3<br>
|
||||
SpeechRecognition<br>
|
||||
os<br>
|
||||
datetime<br>
|
||||
pickle<br>
|
||||
tkinter<br>
|
||||
pygame<br>
|
||||
mutagen<br>
|
||||
time<br>
|
Binary file not shown.
Binary file not shown.
84
scripts/Voice_Assited_Musicplayer/assistant.py
Normal file
84
scripts/Voice_Assited_Musicplayer/assistant.py
Normal file
|
@ -0,0 +1,84 @@
|
|||
import pyttsx3
|
||||
import speech_recognition as sr
|
||||
import datetime
|
||||
import os
|
||||
from player import run
|
||||
|
||||
engine = pyttsx3.init('sapi5')
|
||||
voices = engine.getProperty('voices')
|
||||
engine.setProperty('voice', voices[1].id)
|
||||
|
||||
playlist = []
|
||||
|
||||
|
||||
def speak(audio):
|
||||
engine.say(audio)
|
||||
engine.runAndWait()
|
||||
|
||||
|
||||
def bot_answer(answer):
|
||||
print("assistant:", answer)
|
||||
|
||||
|
||||
def greetings():
|
||||
global playlist
|
||||
hour = int(datetime.datetime.now().hour)
|
||||
if(hour >= 0 and hour < 12):
|
||||
speak("good morning")
|
||||
elif hour >= 12 and hour < 18:
|
||||
speak("good afternoon")
|
||||
else:
|
||||
speak("good evening")
|
||||
|
||||
speak("welcome to py-Musicplayer")
|
||||
bot_answer('say playlist name to play')
|
||||
playlist = os.listdir('Songs')
|
||||
bot_answer(playlist)
|
||||
|
||||
|
||||
def action_taker():
|
||||
r = sr.Recognizer()
|
||||
with sr.Microphone() as source:
|
||||
print("Listening...")
|
||||
speak("listening")
|
||||
r.adjust_for_ambient_noise(source, duration=5)
|
||||
audio = r.listen(source)
|
||||
|
||||
try:
|
||||
print("recognizing...")
|
||||
speak("recognizing")
|
||||
command = r.recognize_google(audio)
|
||||
print(f'User:{command}\n"')
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
bot_answer("Say that again please....")
|
||||
|
||||
return "None"
|
||||
return command
|
||||
|
||||
|
||||
greetings()
|
||||
while True:
|
||||
command = action_taker().lower()
|
||||
song_playlist = list(map(str.lower, playlist))
|
||||
|
||||
if any(command in s for s in song_playlist):
|
||||
get_ind = song_playlist.index(command)
|
||||
playlist_name = playlist.index(command)
|
||||
playlist_name = playlist[get_ind]
|
||||
playlist_dir = os.path.abspath("./Songs/"+playlist_name)
|
||||
bot_answer('Playing: '+playlist_name +
|
||||
'playlist for you with Musicplayer')
|
||||
speak('playing:'+playlist_name+'playlist for you with music player')
|
||||
print(playlist_dir)
|
||||
run(playlist_dir)
|
||||
elif 'stop' in command:
|
||||
speak('good bye,have a good day')
|
||||
bot_answer('exit')
|
||||
engine.stop()
|
||||
break
|
||||
else:
|
||||
bot_answer('did not get the playlist...')
|
||||
speak('did not get the playlist')
|
||||
print(playlist)
|
BIN
scripts/Voice_Assited_Musicplayer/images/image2.gif
Normal file
BIN
scripts/Voice_Assited_Musicplayer/images/image2.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
BIN
scripts/Voice_Assited_Musicplayer/images/next.gif
Normal file
BIN
scripts/Voice_Assited_Musicplayer/images/next.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
scripts/Voice_Assited_Musicplayer/images/pause.gif
Normal file
BIN
scripts/Voice_Assited_Musicplayer/images/pause.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
scripts/Voice_Assited_Musicplayer/images/play.gif
Normal file
BIN
scripts/Voice_Assited_Musicplayer/images/play.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
scripts/Voice_Assited_Musicplayer/images/previous.gif
Normal file
BIN
scripts/Voice_Assited_Musicplayer/images/previous.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
293
scripts/Voice_Assited_Musicplayer/player.py
Normal file
293
scripts/Voice_Assited_Musicplayer/player.py
Normal file
|
@ -0,0 +1,293 @@
|
|||
import time
|
||||
import os
|
||||
import pickle
|
||||
import tkinter as tk
|
||||
from tkinter import Label, filedialog
|
||||
from tkinter import PhotoImage
|
||||
from pygame import mixer
|
||||
from mutagen.mp3 import MP3
|
||||
import tkinter.ttk as ttk
|
||||
from tkinter import messagebox
|
||||
|
||||
|
||||
class Player(tk.Frame):
|
||||
def __init__(self, song_path, master=None):
|
||||
super().__init__(master)
|
||||
self.master = master
|
||||
self.song_path = song_path
|
||||
self.pack()
|
||||
mixer.init()
|
||||
|
||||
if os.path.exists('songs.pickle'):
|
||||
with open('songs.pickle', 'rb') as f:
|
||||
self.playlist = pickle.load(f)
|
||||
else:
|
||||
self.playlist = []
|
||||
|
||||
self.current = 0
|
||||
self.paused = True
|
||||
self.played = False
|
||||
self.song_length = 0
|
||||
|
||||
self.page_layouts()
|
||||
self.track_config()
|
||||
self.control_widgets()
|
||||
self.song_list()
|
||||
self.retrieve_songs2()
|
||||
|
||||
def page_layouts(self):
|
||||
self.track = tk.LabelFrame(self, text='Song Track',
|
||||
font=("times new roman", 15, "bold"),
|
||||
bg="black", fg="white", bd=5, relief=tk.GROOVE)
|
||||
self.track.config(width=400, height=300)
|
||||
self.track.grid(row=0, column=0, padx=1)
|
||||
|
||||
self.tracklist = tk.LabelFrame(self, text=f'PlayList - {str(len(self.playlist))}',
|
||||
font=("times new roman", 12, "bold"),
|
||||
bg="black", fg="white", bd=5, relief=tk.GROOVE)
|
||||
self.tracklist.config(width=190, height=200)
|
||||
self.tracklist.grid(row=0, column=1, pady=1)
|
||||
|
||||
self.controls = tk.LabelFrame(self,
|
||||
font=("times new roman", 15, "bold"),
|
||||
bg="black", fg="white", bd=2, relief=tk.GROOVE)
|
||||
self.controls.config(width=410, height=80)
|
||||
self.controls.grid(row=2, column=0, pady=1, padx=1)
|
||||
|
||||
self.music_slider = tk.LabelFrame(self,
|
||||
font=("times new roman", 15, "bold"),
|
||||
bg="black", fg="white", bd=5, relief=tk.GROOVE)
|
||||
self.music_slider.config(width=410, height=80)
|
||||
self.music_slider.grid(row=3, column=0, pady=1, padx=1)
|
||||
|
||||
self.func = tk.LabelFrame(self,
|
||||
font=("times new roman", 12, "bold"),
|
||||
bg="black", fg="white", bd=5, relief=tk.GROOVE)
|
||||
self.func.config(width=250, height=210)
|
||||
self.func.grid(row=3, column=1)
|
||||
|
||||
self.promo = tk.LabelFrame(self,
|
||||
bg="black", fg="white", bd=5, relief=tk.GROOVE)
|
||||
self.promo.config(width=50, height=50)
|
||||
self.promo.grid(row=2, column=1)
|
||||
|
||||
def track_config(self):
|
||||
self.views = tk.Label(self.track, image=img)
|
||||
self.views.configure(width=400, height=240)
|
||||
self.views.grid(row=0, column=0)
|
||||
|
||||
self.musictrack = tk.Label(self.track, font=("times new roman", 16, "bold"),
|
||||
bg="white", fg="dark blue")
|
||||
self.musictrack['text'] = 'MP3 Player'
|
||||
self.musictrack.config(width=30, height=1)
|
||||
self.musictrack.grid(row=1, column=0, padx=10)
|
||||
|
||||
def control_widgets(self):
|
||||
self.loading = tk.Button(
|
||||
self.controls, bg='green', fg='white', font=10)
|
||||
self.loading['text'] = 'Load Songs'
|
||||
self.loading['command'] = self.retrieve_songs
|
||||
self.loading.grid(row=0, column=0, padx=10)
|
||||
|
||||
self.prev = tk.Button(self.controls, image=prev)
|
||||
self.prev['command'] = self.prev_song
|
||||
self.prev.grid(row=0, column=1)
|
||||
|
||||
self.pause = tk.Button(self.controls, image=pause)
|
||||
self.pause['command'] = self.pause_song
|
||||
self.pause.grid(row=0, column=2)
|
||||
|
||||
self.next = tk.Button(self.controls, image=next_)
|
||||
self.next['command'] = self.next_song
|
||||
self.next.grid(row=0, column=3)
|
||||
|
||||
self.volume = tk.DoubleVar(self)
|
||||
self.slider = tk.Scale(self.controls, from_=0,
|
||||
to=10, orient=tk.HORIZONTAL)
|
||||
self.slider['variable'] = self.volume
|
||||
self.slider.set(5)
|
||||
mixer.music.set_volume(1)
|
||||
self.slider['command'] = self.change_volume
|
||||
self.slider.grid(row=0, column=4, padx=10, pady=4)
|
||||
|
||||
self.mu_slider = ttk.Scale(self.music_slider, from_=0, to=100,
|
||||
orient=tk.HORIZONTAL, value=0, length=390)
|
||||
self.mu_slider.grid(pady=20, padx=10)
|
||||
|
||||
self.status_bar = Label(self.music_slider, text="Time Elapsed: 0/0")
|
||||
self.status_bar.grid(pady=1)
|
||||
|
||||
self.delet = tk.Button(self.func, text="Delete", bg='green', fg='white', font=15)
|
||||
self.delet['command'] = self.delete_songs
|
||||
self.delet.grid(row=0, column=1, padx=39, pady=29)
|
||||
|
||||
self.prom = tk.Label(self.promo, text="artgoblin's work", font=("times new roman", 10, "bold", "italic"),
|
||||
bg="grey", fg="black")
|
||||
self.prom.grid(row=0, column=2, padx=20, pady=12)
|
||||
|
||||
def song_list(self):
|
||||
self.scrollbar = tk.Scrollbar(self.tracklist, orient=tk.VERTICAL)
|
||||
self.scrollbar.grid(row=0, column=1, rowspan=5, sticky='ns')
|
||||
|
||||
self.list = tk.Listbox(self.tracklist, selectmode=tk.SINGLE,
|
||||
yscrollcommand=self.scrollbar.set, selectbackground='sky blue')
|
||||
self.enum_songs()
|
||||
self.list.config(height=17)
|
||||
self.list.bind('<Double-1>', self.play_song)
|
||||
|
||||
self.scrollbar.config(command=self.list.yview)
|
||||
self.list.grid(row=0, column=0, rowspan=5)
|
||||
|
||||
def retrieve_songs2(self):
|
||||
self.songlist2 = []
|
||||
os.chdir(self.song_path)
|
||||
|
||||
for files in os.listdir(self.song_path):
|
||||
try:
|
||||
if files.endswith(".mp3"):
|
||||
|
||||
self.songlist2.append(files)
|
||||
elif files.endswith(".wav"):
|
||||
|
||||
self.songlist2.append(files)
|
||||
elif files.endswith(".mpeg"):
|
||||
|
||||
self.songlist2.append(files)
|
||||
except:
|
||||
pass
|
||||
|
||||
with open('songs2.pickle', 'wb') as f:
|
||||
pickle.dump(self.songlist2, f)
|
||||
self.playlist = self.songlist2
|
||||
self.tracklist['text'] = f'PlayList - {str(len(self.playlist))}'
|
||||
self.list.delete(0, tk.END)
|
||||
|
||||
self.enum_songs()
|
||||
|
||||
def retrieve_songs(self):
|
||||
self.songlist = []
|
||||
|
||||
directory = filedialog.askdirectory()
|
||||
for root_, dirs, files in os.walk(directory):
|
||||
for file in files:
|
||||
if os.path.splitext(file)[1] == '.mp3':
|
||||
path = (root_ + '/' + file).replace('\\', '/')
|
||||
self.songlist.append(path)
|
||||
elif os.path.splitext(file)[1] == '.mpeg':
|
||||
path = (root_ + '/' + file).replace('\\', '/')
|
||||
self.songlist.append(path)
|
||||
elif os.path.splitext(file)[1] == '.wav':
|
||||
path = (root_ + '/' + file).replace('\\', '/')
|
||||
self.songlist.append(path)
|
||||
|
||||
with open('songs.pickle', 'wb') as f:
|
||||
pickle.dump(self.songlist, f)
|
||||
self.playlist = self.songlist
|
||||
self.tracklist['text'] = f'PlayList - {str(len(self.playlist))}'
|
||||
self.list.delete(0, tk.END)
|
||||
self.enum_songs()
|
||||
|
||||
def enum_songs(self):
|
||||
for index, song in enumerate(self.playlist):
|
||||
self.list.insert(index, os.path.basename(song))
|
||||
|
||||
def play_song(self, event=None):
|
||||
if event is not None:
|
||||
self.current = self.list.curselection()[0]
|
||||
for i in range(len(self.playlist)):
|
||||
self.list.itemconfigure(i, bg="white")
|
||||
|
||||
print(self.playlist[self.current])
|
||||
mixer.music.load(self.playlist[self.current])
|
||||
self.m = mixer.music.load(self.playlist[self.current])
|
||||
self.musictrack['anchor'] = 'w'
|
||||
self.musictrack['text'] = os.path.basename(self.playlist[self.current])
|
||||
|
||||
self.pause['image'] = play
|
||||
self.paused = False
|
||||
self.played = True
|
||||
self.list.activate(self.current)
|
||||
self.list.itemconfigure(self.current, bg='sky blue')
|
||||
|
||||
mixer.music.play()
|
||||
self.update_progress()
|
||||
|
||||
def update_progress(self):
|
||||
song_mut = MP3(self.playlist[self.current])
|
||||
self.song_length = song_mut.info.length
|
||||
slider_position = int(self.song_length)
|
||||
self.mu_slider.config(to=slider_position)
|
||||
pos_ms = mixer.music.get_pos() / 1000
|
||||
self.mu_slider.config(value=pos_ms)
|
||||
clock = time.strftime('%M:%S', time.gmtime(self.song_length))
|
||||
clock2 = time.strftime('%M:%S', time.gmtime(pos_ms))
|
||||
self.status_bar.config(text=f'Time Elapsed: {clock2} / {clock} ')
|
||||
self.after(1000, self.update_progress)
|
||||
|
||||
def pause_song(self):
|
||||
if not self.paused:
|
||||
self.paused = True
|
||||
mixer.music.pause()
|
||||
self.pause['image'] = pause
|
||||
else:
|
||||
if self.played == False:
|
||||
self.play_song()
|
||||
self.paused = False
|
||||
mixer.music.unpause()
|
||||
self.pause['image'] = play
|
||||
|
||||
def prev_song(self):
|
||||
if self.current > 0:
|
||||
self.current -= 1
|
||||
else:
|
||||
self.current = 0
|
||||
self.list.itemconfigure(self.current + 1, bg='white')
|
||||
self.play_song()
|
||||
|
||||
def next_song(self):
|
||||
if self.current < len(self.playlist) - 1:
|
||||
self.current += 1
|
||||
else:
|
||||
self.current = 0
|
||||
self.list.itemconfigure(self.current - 1, bg='white')
|
||||
self.play_song()
|
||||
|
||||
def change_volume(self, event=None):
|
||||
self.v = self.volume.get()
|
||||
mixer.music.set_volume(self.v / 10)
|
||||
|
||||
def delete_songs(self, event=None):
|
||||
items = map(int, self.list.curselection())
|
||||
for item in items:
|
||||
self.list.delete(item)
|
||||
self.playlist.pop(item)
|
||||
self.tracklist['text'] = 'Total Songs: ' + str(len( self.playlist))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def run(song_path):
|
||||
global img, prev, play, next_, pause
|
||||
root = tk.Tk()
|
||||
root.title('MP3 Player')
|
||||
root.geometry("572x458")
|
||||
|
||||
def on_closing():
|
||||
|
||||
if messagebox.askokcancel("Quit", "Do you want to quit?"):
|
||||
|
||||
mixer.music.stop()
|
||||
root.destroy()
|
||||
root.protocol("WM_DELETE_WINDOW", on_closing)
|
||||
|
||||
os.path.join(os.path.curdir, 'file.name')
|
||||
|
||||
img = PhotoImage(file=os.path.join(os.path.curdir, 'images/image2.gif'))
|
||||
next_ = PhotoImage(file=os.path.join(os.path.curdir, 'images/next.gif'))
|
||||
prev = PhotoImage(file=os.path.join(os.path.curdir, 'images/previous.gif'))
|
||||
play = PhotoImage(file=os.path.join(os.path.curdir, 'images/play.gif'))
|
||||
pause = PhotoImage(file=os.path.join(os.path.curdir, 'images/pause.gif'))
|
||||
|
||||
app = Player(song_path, master=root)
|
||||
app.mainloop()
|
Loading…
Reference in New Issue
Block a user