From 99904127fa2312bfaa642959d5a539d2346a068a Mon Sep 17 00:00:00 2001 From: Siddhrajsinh Ranjitsinh Gohil <61483081+sidddev7@users.noreply.github.com> Date: Wed, 21 Oct 2020 08:51:14 +0530 Subject: [PATCH 01/10] Create text to speech this code will speak the text for you --- text to speech/text to speech | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 text to speech/text to speech diff --git a/text to speech/text to speech b/text to speech/text to speech new file mode 100644 index 0000000..c270d50 --- /dev/null +++ b/text to speech/text to speech @@ -0,0 +1,6 @@ +# install the python module pyttsx3 +import pyttsx3 +speaker=pyttsx3.init() +text=input("Enter the sentence that you want to speak") +speaker.say(text) +speaker.runAndWait() From b5469b1267a5ce18db818909d4e7af4586df7be8 Mon Sep 17 00:00:00 2001 From: Siddhrajsinh Ranjitsinh Gohil <61483081+sidddev7@users.noreply.github.com> Date: Wed, 21 Oct 2020 08:53:24 +0530 Subject: [PATCH 02/10] Create pdf to speech this code will speak the pdf page for you --- text to speech/pdf to speech | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 text to speech/pdf to speech diff --git a/text to speech/pdf to speech b/text to speech/pdf to speech new file mode 100644 index 0000000..b247e99 --- /dev/null +++ b/text to speech/pdf to speech @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +# you will need 2 python libraries +#1. pyttx3 +#2. PyPDF2 + +import pyttsx3 +import PyPDF2 + +book=open('your pdf file location','rb') + +pdfreader=PyPDF2.PdfFileReader(book) + +pages=pdfreader.numPages +#print(pages) +#select the page number that you want python program to narrate +page=pdfreader.getPage(30) + +text=page.extractText() + +speaker=pyttsx3.init() + +speaker.say(text) + +speaker.runAndWait() From b6fb38f57a221ae03ea086eec70effbc313a11ba Mon Sep 17 00:00:00 2001 From: Abhishek Ranjan <73399221+AbhihsekRanjan0408@users.noreply.github.com> Date: Sun, 25 Oct 2020 00:12:01 +0530 Subject: [PATCH 03/10] Create ATM BANKING PYHTON CODE --- ATM BANKING PYHTON CODE | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 ATM BANKING PYHTON CODE diff --git a/ATM BANKING PYHTON CODE b/ATM BANKING PYHTON CODE new file mode 100644 index 0000000..6483149 --- /dev/null +++ b/ATM BANKING PYHTON CODE @@ -0,0 +1,58 @@ +print('Welcome to Northen Frock Bank ATM') +restart=('Y') +chances = 3 +balance = 67.14 +while chances >= 0: + pin = int(input('Please Enter You 4 Digit Pin: ')) + if pin == (1234): + print('You entered you pin Correctly\n') + while restart not in ('n','NO','no','N'): + print('Please Press 1 For Your Balance\n') + print('Please Press 2 To Make a Withdrawl\n') + print('Please Press 3 To Pay in\n') + print('Please Press 4 To Return Card\n') + option = int(input('What Would you like to choose?')) + if option == 1: + print('Your Balance is £',balance,'\n') + restart = input('Would You you like to go back? ') + if restart in ('n','NO','no','N'): + print('Thank You') + break + elif option == 2: + option2 = ('y') + withdrawl = float(input('How Much Would you like to +withdraw? \n£10/£20/£40/£60/£80/£100 for other enter 1: ')) + if withdrawl in [10, 20, 40, 60, 80, 100]: + balance = balance - withdrawl + print ('\nYour Balance is now £',balance) + restart = input('Would You you like to go back? ') + if restart in ('n','NO','no','N'): + print('Thank You') + break + elif withdrawl != [10, 20, 40, 60, 80, 100]: + print('Invalid Amount, Please Re-try\n') + restart = ('y') + elif withdrawl == 1: + withdrawl = float(input('Please Enter Desired amount:')) + + elif option == 3: + Pay_in = float(input('How Much Would You Like To Pay In? ')) + balance = balance + Pay_in + print ('\nYour Balance is now £',balance) + restart = input('Would You you like to go back? ') + if restart in ('n','NO','no','N'): + print('Thank You') + break + elif option == 4: + print('Please wait whilst your card is Returned...\n') + print('Thank you for you service') + break + else: + print('Please Enter a correct number. \n') + restart = ('y') + elif pin != ('1234'): + print('Incorrect Password') + chances = chances - 1 + if chances == 0: + print('\nNo more tries') + break From a7c7b1be71eeb72be4ac039747c50e5201698f14 Mon Sep 17 00:00:00 2001 From: Aziz Vohra Date: Thu, 29 Oct 2020 09:27:53 +0530 Subject: [PATCH 04/10] Create Qr code Generator --- Qr code Generator | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Qr code Generator diff --git a/Qr code Generator b/Qr code Generator new file mode 100644 index 0000000..f49552c --- /dev/null +++ b/Qr code Generator @@ -0,0 +1,17 @@ +# Import QRCode from pyqrcode +import pyqrcode +import png +from pyqrcode import QRCode + + +# String which represents the QR code +s = "www.geeksforgeeks.org" + +# Generate QR code +url = pyqrcode.create(s) + +# Create and save the svg file naming "myqr.svg" +url.svg("myqr.svg", scale = 8) + +# Create and save the png file naming "myqr.png" +url.png('myqr.png', scale = 6) From 8f8128d019f0720a5a141039db941f963da9a939 Mon Sep 17 00:00:00 2001 From: Aziz Vohra Date: Thu, 29 Oct 2020 09:34:31 +0530 Subject: [PATCH 05/10] Create Email Slicer Created Email Slicer with Python --- Email Slicer | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Email Slicer diff --git a/Email Slicer b/Email Slicer new file mode 100644 index 0000000..8e05d0e --- /dev/null +++ b/Email Slicer @@ -0,0 +1,5 @@ +email=input("What is the email address:").strip() +user = email[:email.index("@")] +domain = email[email.index("@")+1:] +output = "Your email is {} and your username is {} and domain is {}".format(email,user,domain) +print(output) From 6a54566d5cb20e104124a39d5cdfba23037d8814 Mon Sep 17 00:00:00 2001 From: Aziz Vohra Date: Thu, 29 Oct 2020 09:38:22 +0530 Subject: [PATCH 06/10] Create Audio processing using Pydub Required Installations: pip3 install pydub pip3 install audioread pip3 install SpeechRecognition --- Audio processing using Pydub | 134 +++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 Audio processing using Pydub diff --git a/Audio processing using Pydub b/Audio processing using Pydub new file mode 100644 index 0000000..c76c15c --- /dev/null +++ b/Audio processing using Pydub @@ -0,0 +1,134 @@ +# Import necessary libraries +from pydub import AudioSegment +import speech_recognition as sr + +# Input audio file to be sliced +audio = AudioSegment.from_wav("1.wav") + +''' +Step #1 - Slicing the audio file into smaller chunks. +''' +# Length of the audiofile in milliseconds +n = len(audio) + +# Variable to count the number of sliced chunks +counter = 1 + +# Text file to write the recognized audio +fh = open("recognized.txt", "w+") + +# Interval length at which to slice the audio file. +# If length is 22 seconds, and interval is 5 seconds, +# The chunks created will be: +# chunk1 : 0 - 5 seconds +# chunk2 : 5 - 10 seconds +# chunk3 : 10 - 15 seconds +# chunk4 : 15 - 20 seconds +# chunk5 : 20 - 22 seconds +interval = 5 * 1000 + +# Length of audio to overlap. +# If length is 22 seconds, and interval is 5 seconds, +# With overlap as 1.5 seconds, +# The chunks created will be: +# chunk1 : 0 - 5 seconds +# chunk2 : 3.5 - 8.5 seconds +# chunk3 : 7 - 12 seconds +# chunk4 : 10.5 - 15.5 seconds +# chunk5 : 14 - 19.5 seconds +# chunk6 : 18 - 22 seconds +overlap = 1.5 * 1000 + +# Initialize start and end seconds to 0 +start = 0 +end = 0 + +# Flag to keep track of end of file. +# When audio reaches its end, flag is set to 1 and we break +flag = 0 + +# Iterate from 0 to end of the file, +# with increment = interval +for i in range(0, 2 * n, interval): + + # During first iteration, + # start is 0, end is the interval + if i == 0: + start = 0 + end = interval + + # All other iterations, + # start is the previous end - overlap + # end becomes end + interval + else: + start = end - overlap + end = start + interval + + # When end becomes greater than the file length, + # end is set to the file length + # flag is set to 1 to indicate break. + if end >= n: + end = n + flag = 1 + + # Storing audio file from the defined start to end + chunk = audio[start:end] + + # Filename / Path to store the sliced audio + filename = 'chunk'+str(counter)+'.wav' + + # Store the sliced audio file to the defined path + chunk.export(filename, format ="wav") + # Print information about the current chunk + print("Processing chunk "+str(counter)+". Start = " + +str(start)+" end = "+str(end)) + + # Increment counter for the next chunk + counter = counter + 1 + + # Slicing of the audio file is done. + # Skip the below steps if there is some other usage + # for the sliced audio files. + + +''' +Step #2 - Recognizing the chunk and writing to a file. +''' + + # Here, Google Speech Recognition is used + # to take each chunk and recognize the text in it. + + # Specify the audio file to recognize + + AUDIO_FILE = filename + + # Initialize the recognizer + r = sr.Recognizer() + + # Traverse the audio file and listen to the audio + with sr.AudioFile(AUDIO_FILE) as source: + audio_listened = r.listen(source) + + # Try to recognize the listened audio + # And catch expections. + try: + rec = r.recognize_google(audio_listened) + + # If recognized, write into the file. + fh.write(rec+" ") + + # If google could not understand the audio + except sr.UnknownValueError: + print("Could not understand audio") + + # If the results cannot be requested from Google. + # Probably an internet connection error. + except sr.RequestError as e: + print("Could not request results.") + + # Check for flag. + # If flag is 1, end of the whole audio reached. + # Close the file and break. + if flag == 1: + fh.close() + break From 579f032d718c2df24506b0fc22bc81e6e7e0abe7 Mon Sep 17 00:00:00 2001 From: Aziz Vohra Date: Thu, 29 Oct 2020 09:39:48 +0530 Subject: [PATCH 07/10] Create Image Processing in Python --- Image Processing in Python | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Image Processing in Python diff --git a/Image Processing in Python b/Image Processing in Python new file mode 100644 index 0000000..5dd520a --- /dev/null +++ b/Image Processing in Python @@ -0,0 +1,34 @@ +# using matplotlib and numpy + +import matplotlib.image as img +import numpy as npy + +# provide the location of image for reading +m = img.imread("taj.png"); + +# determining the length of original image +w, h = m.shape[:2]; + +# xNew and yNew are new width and +# height of image required +after scaling +xNew = int(w * 1 / 2); +yNew = int(h * 1 / 2); + +# calculating the scaling factor +# work for more than 2 pixel +xScale = xNew/(w-1); +yScale = yNew/(h-1); + +# using numpy taking a matrix of xNew +# width and yNew height with +# 4 attribute [alpha, B, G, B] values +newImage = npy.zeros([xNew, yNew, 4]); + +for i in range(xNew-1): + for j in range(yNew-1): + newImage[i + 1, j + 1]= m[1 + int(i / xScale), + 1 + int(j / yScale)] + +# Save the image after scaling +img.imsave('scaled.png', newImage); From a63938dfc39f20f200dd49b2bf90da7bfe8c3e75 Mon Sep 17 00:00:00 2001 From: Siddhrajsinh Ranjitsinh Gohil <61483081+sidddev7@users.noreply.github.com> Date: Mon, 18 Oct 2021 19:56:51 +0530 Subject: [PATCH 08/10] Update pdf to speech --- text to speech/pdf to speech | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/text to speech/pdf to speech b/text to speech/pdf to speech index b247e99..0386b4b 100644 --- a/text to speech/pdf to speech +++ b/text to speech/pdf to speech @@ -4,20 +4,26 @@ #1. pyttx3 #2. PyPDF2 +#Importing the Libraries import pyttsx3 import PyPDF2 +#opening the book into the file reader book=open('your pdf file location','rb') +#using pdf reader pdfreader=PyPDF2.PdfFileReader(book) +##reading the pages pages=pdfreader.numPages #print(pages) #select the page number that you want python program to narrate page=pdfreader.getPage(30) +#extracting the page contents text=page.extractText() +#speaking the extracted text speaker=pyttsx3.init() speaker.say(text) From a2bf9979ad1af8c701b034e1260ba100a744f8a6 Mon Sep 17 00:00:00 2001 From: Siddhrajsinh Ranjitsinh Gohil <61483081+sidddev7@users.noreply.github.com> Date: Mon, 2 Oct 2023 22:52:06 +0530 Subject: [PATCH 09/10] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index d819bb3..a8578eb 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ # Python-codes small python codes for specific functionalities like Text to speech,Qr code,Speech to text, + + +### this repo contains many useful resources for the python containing multiple ready to use codes From a6fcf6fd21c253c81daa3a27365f5a3fd52dff29 Mon Sep 17 00:00:00 2001 From: Siddhrajsinh Ranjitsinh Gohil <61483081+sidddev7@users.noreply.github.com> Date: Tue, 3 Oct 2023 08:38:45 +0530 Subject: [PATCH 10/10] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a8578eb..7939b3b 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,5 @@ like Text to speech,Qr code,Speech to text, ### this repo contains many useful resources for the python containing multiple ready to use codes + +Contact me on sidraj2019@gmail.com for more info