Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit bf3692b

Browse files
authored
Merge branch 'main' into new
2 parents 022ea52 + f6a71c0 commit bf3692b

135 files changed

Lines changed: 37346 additions & 441 deletions

File tree

Some content is hidden

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

README.md

Lines changed: 328 additions & 106 deletions
Large diffs are not rendered by default.

data/banner-simple.png

2.88 MB
Loading

data/banner_hacktoberfest.png

2.87 MB
Loading

projects/AWS_s3_upload/main.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import boto3
2+
from botocore.exceptions import NoCredentialsError
3+
4+
ACCESS_KEY = ""
5+
SECRET_KEY = ""
6+
LOCAL_FILE = "local_file_name"
7+
BUCKET_NAME = "bucket_name"
8+
S3_FILE_NAME = "file_name_on_s3"
9+
10+
11+
def upload_to_s3(local_file, bucket, s3_file):
12+
## This function is responsible for uploading the file into the S3 bucket using the specified credentials.
13+
s3 = boto3.client(
14+
"s3", aws_access_key_id=ACCESS_KEY, aws_secret_access_key=SECRET_KEY
15+
)
16+
try:
17+
s3.upload_file(local_file, bucket, s3_file)
18+
print("Upload Successful")
19+
return True
20+
except FileNotFoundError:
21+
print("The file was not found")
22+
return False
23+
except NoCredentialsError:
24+
print("Credentials not available")
25+
return False
26+
27+
28+
result = upload_to_s3(LOCAL_FILE, BUCKET_NAME, S3_FILE_NAME)

projects/AWS_s3_upload/readme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
## Simple Python script for AWS S3 file upload.
3+
4+
### Prerequisites
5+
boto3 (pip install boto3) <br />
6+
7+
### How to run the script
8+
- Specify both ACCESS_KEY and SECRET_KEY. You can get them both on your AWS account in "My Security Credentials" section. <br />
9+
- Specify the local file name, bucket name and the name that you want the file to have inside s3 bucket using LOCAL_FILE, BUCKET_NAME and S3_FILE_NAME variables. <br />
10+
- Run "python main.py" <br />
11+
12+
### Author Name
13+
Yashvardhan Singh https://github.com/pythonicboat
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
boto3==1.20.4
2+
botocore==1.23.4
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import tkinter as tk
2+
from math import sin, cos, pi
3+
4+
def update_clock():
5+
current_time = time_var.get()
6+
seconds = current_time % 60
7+
minutes = (current_time // 60) % 60
8+
hours = (current_time // 3600) % 12
9+
10+
seconds_angle = 90 - seconds * 6
11+
minutes_angle = 90 - minutes * 6 - seconds * 0.1
12+
hours_angle = 90 - (hours * 30 + minutes * 0.5)
13+
14+
canvas.delete("all")
15+
16+
canvas.create_oval(50, 50, 250, 250)
17+
18+
for i in range(1, 13):
19+
angle = 90 - i * 30
20+
x = 150 + 85 * cos(angle * (pi / 180))
21+
y = 150 - 85 * sin(angle * (pi / 180))
22+
canvas.create_text(x, y, text=str(i), font=("Arial", 12, "bold"))
23+
24+
draw_hand(150, 150, seconds_angle, 80, 1)
25+
draw_hand(150, 150, minutes_angle, 70, 2)
26+
draw_hand(150, 150, hours_angle, 50, 4)
27+
28+
time_var.set(current_time + 1)
29+
30+
root.after(1000, update_clock)
31+
32+
def draw_hand(x, y, angle, length, width):
33+
radian_angle = angle * (pi / 180)
34+
end_x = x + length * cos(radian_angle)
35+
end_y = y - length * sin(radian_angle)
36+
canvas.create_line(x, y, end_x, end_y, width=width)
37+
38+
root = tk.Tk()
39+
root.title("Analog Clock")
40+
41+
canvas = tk.Canvas(root, width=350, height=350)
42+
canvas.pack()
43+
44+
time_var = tk.IntVar()
45+
time_var.set(10 * 3600)
46+
47+
update_clock()
48+
root.mainloop()
49+

projects/AnalogClock/analog_clock

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import tkinter as tk
2+
from math import sin, cos, pi
3+
4+
def update_clock():
5+
current_time = time_var.get()
6+
seconds = current_time % 60
7+
minutes = (current_time // 60) % 60
8+
hours = (current_time // 3600) % 12
9+
10+
# Calculation of the angles for the clock hands (in degrees)
11+
seconds_angle = 90 - seconds * 6
12+
minutes_angle = 90 - minutes * 6 - seconds * 0.1
13+
hours_angle = 90 - (hours * 30 + minutes * 0.5)
14+
15+
canvas.delete("all") #Deletes all previous drawings
16+
17+
canvas.create_oval(50, 50, 250, 250) #To draw clock face
18+
19+
for i in range(1, 13): # Drawing clock numbers
20+
angle = 90 - i * 30 #Calculation of the angle for each number
21+
x = 150 + 85 * cos(angle * (pi / 180))
22+
y = 150 - 85 * sin(angle * (pi / 180))
23+
canvas.create_text(x, y, text=str(i), font=("Arial", 12, "bold"))
24+
25+
draw_hand(150, 150, seconds_angle, 80, 1)
26+
draw_hand(150, 150, minutes_angle, 70, 2)
27+
draw_hand(150, 150, hours_angle, 50, 4)
28+
29+
time_var.set(current_time + 1) # Updating the time
30+
31+
root.after(1000, update_clock) # Updating the clock every 1000ms (1 second)
32+
33+
def draw_hand(x, y, angle, length, width):
34+
radian_angle = angle * (pi / 180)
35+
end_x = x + length * cos(radian_angle)
36+
end_y = y - length * sin(radian_angle)
37+
canvas.create_line(x, y, end_x, end_y, width=width)
38+
39+
root = tk.Tk() # Creating the main window
40+
root.title("Analog Clock")
41+
42+
canvas = tk.Canvas(root, width=350, height=350)
43+
canvas.pack()
44+
45+
time_var = tk.IntVar()
46+
time_var.set(10 * 3600)
47+
48+
update_clock() # Starting the clock update function
49+
root.mainloop() # Running the Tkinter main loop
50+

projects/AudioAPI/ReadMe.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Unofficial Whisper API
2+
3+
## Overview
4+
5+
Welcome to the Unofficial Whisper API documentation. This API allows you to utilize OpenAI's Whisper, a versatile speech recognition model trained on vast amounts of multilingual data, without the need for OpenAI API credits. With the Unofficial Whisper API, you can convert audio files into text transcripts with ease.
6+
7+
## Requirements
8+
9+
Before using the Unofficial Whisper API, ensure you have the following prerequisites:
10+
11+
1. **Python 3.x**: Make sure you have Python 3.x installed on your system.
12+
13+
2. **OpenAI's Whisper**: Install OpenAI's Whisper model on your system. You can find installation instructions on the [OpenAI Whisper GitHub repository](https://github.com/openai/whisper).
14+
15+
3. **Python's Flask**: Install Flask, a micro-web framework for Python, to run the API. You can install Flask using pip:
16+
17+
```bash
18+
pip install Flask
19+
20+
## Getting Started
21+
22+
1. Clone the repository
23+
2. Run transcription.py
24+
3. Open a new terminal, run this command - curl -X POST -F "audio=@C:path_to_your_audio_file" http://localhost:5000/transcribe
25+
26+
27+
## Output Formats
28+
29+
The Unofficial Whisper API provides transcription output in various formats:
30+
31+
Text: The transcribed text as a plain text string.
32+
VTT (WebVTT): Transcribed text with timestamps in the WebVTT format for easy integration with video players.
33+
SRT (SubRip): Transcribed text with timestamps in the SubRip format, suitable for subtitles.

projects/AudioAPI/transcription.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from flask import Flask, request, jsonify, send_file
2+
from werkzeug.utils import secure_filename
3+
from datetime import timedelta
4+
import os
5+
import whisper
6+
7+
app = Flask(__name__)
8+
9+
10+
@app.route("/transcribe", methods=["POST"])
11+
def transcribe():
12+
# check if the post request has the file part
13+
if "audio" not in request.files:
14+
return jsonify({"error": "No audio file found."}), 400
15+
16+
file = request.files["audio"]
17+
18+
if file.filename == "":
19+
return jsonify({"error": "No audio file selected."}), 400
20+
21+
if not allowed_file(file.filename):
22+
return (
23+
jsonify({"error": "Only WAV, MP3, and OGG audio files are allowed."}),
24+
400,
25+
)
26+
27+
filename = secure_filename(file.filename)
28+
file.save(filename)
29+
30+
model = whisper.load_model("small") # Change this to your desired model
31+
print("Whisper model loaded.")
32+
transcribe = model.transcribe(audio=filename)
33+
segments = transcribe["segments"]
34+
35+
srt_file = open("subtitles.vtt", "w", encoding="utf-8")
36+
srt_file.write("WEBVTT\n\n")
37+
38+
for segment in segments:
39+
startTime = str(0) + str(timedelta(seconds=int(segment["start"]))) + ".000"
40+
endTime = str(0) + str(timedelta(seconds=int(segment["end"]))) + ".000"
41+
text = segment["text"]
42+
segmentId = segment["id"] + 1
43+
segment = f"{segmentId}\n{startTime} --> {endTime}\n{text[1:] if text[0] == ' ' else text}\n\n"
44+
45+
srt_file.write(segment)
46+
47+
srt_file.close()
48+
os.remove(filename)
49+
50+
return send_file(
51+
"subtitles.vtt",
52+
as_attachment=True,
53+
download_name="subtitles.vtt",
54+
mimetype="text/vtt",
55+
)
56+
57+
58+
def allowed_file(filename):
59+
return "." in filename and filename.rsplit(".", 1)[1].lower() in [
60+
"wav",
61+
"mp3",
62+
"ogg",
63+
]
64+
65+
66+
if __name__ == "__main__":
67+
app.run()

0 commit comments

Comments
 (0)