This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Merge Sort in Python | |
| def mergeSort(array): | |
| if len(array) > 1: | |
| # r is the point where the array is divided into two subarrays | |
| r = len(array)//2 | |
| L = array[:r] | |
| M = array[r:] | |
| # Sort the two halves by recursive method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # MergeSort in Python | |
| def mergeSort(array): | |
| if len(array) > 1: | |
| # r is the point where the array is divided into two subarrays | |
| r = len(array)//2 | |
| L = array[:r] | |
| M = array[r:] | |
| # Sort the two halves by recursive method |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Quick Sort in Python | |
| #finding the partition position | |
| def partition(array, lowest, highest): | |
| # choose the rightmost element as pivot | |
| pivot = array[highest] | |
| # pointer for greater element | |
| i = lowest - 1 | |
| # compare each element with pivot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Insertion sort in Python | |
| def insertionSort(array): | |
| for step in range(1, len(array)): | |
| key = array[step] | |
| j = step - 1 | |
| # Compare key with each element on the left of it until an element smaller than it is found | |
| while j >= 0 and key < array[j]: | |
| array[j + 1] = array[j] | |
| j = j - 1 | |
| # Place key at after the element just smaller than it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Bubble sort in Python | |
| def bubbleSort(array): | |
| # Outer loop to access each element of array | |
| for i in range(len(array)): | |
| # inner loop to compare array elements with outer loop iteration element | |
| for j in range(0, len(array) - i - 1): | |
| # compare two adjacent elements |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pyttsx3 | |
| engine = pyttsx3.init() | |
| """Saving Voice to a file""" | |
| # On linux make sure that 'espeak' and 'ffmpeg' are installed | |
| #saving and runing | |
| engine.save_to_file("I'm a Programmer", 'test.mp3') | |
| engine.runAndWait() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pyttsx3 | |
| #changing voice | |
| engine = pyttsx3.init(driverName='sapi5') | |
| engine.say("I'm a Programmer') | |
| engine.runAndWait() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #importing module | |
| import pyttsx3 | |
| #initializing the engine | |
| engine = pyttsx3.init() | |
| engine.say("I'm a Coder") | |
| """VOICE""" | |
| voices = engine.getProperty('voices') # getting details of current voice | |
| #engine.setProperty('voice', voices[0].id) # changes voices. o for male |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #importing module | |
| import pyttsx3 | |
| #initializing the engine | |
| engine = pyttsx3.init() | |
| engine.say("I'm a Coder") | |
| """ RATE""" | |
| rate = engine.getProperty('rate') # getting details of current speaking rate | |
| print (rate) # print the current voice rate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #importing module | |
| import pyttsx3 | |
| #initializing the engine | |
| engine = pyttsx3.init() | |
| engine.say("I'm a Coder") | |
| #running code | |
| engine.runAndWait() |
NewerOlder