Created
September 21, 2022 18:22
-
-
Save Developer-Incoming/67bfce7efa7264756e6c6047490a8b2e to your computer and use it in GitHub Desktop.
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
''' | |
n = Number | |
b = Base | |
p = Position | |
nb^p = Decimal | |
''' | |
debug = True | |
''' | |
[ character , it's value ] | |
For example: | |
["X", 55] | |
so, the value of X is 55 | |
if we replace X with 1, 1 it's value is going to change to 55, if it's stringed. | |
''' | |
valuesList = [ | |
["0", 0], | |
["1", 1], | |
["2", 2], | |
["3", 3], | |
["4", 4], | |
["5", 5], | |
["6", 6], | |
["7", 7], | |
["8", 8], | |
["9", 9], | |
["a", 10], | |
["b", 11], | |
["c", 12], | |
["d", 13], | |
["e", 14], | |
["f", 15], | |
["g", 16], | |
["h", 17], | |
["i", 18], | |
["j", 19], | |
["k", 20], | |
["l", 21], | |
["m", 22], | |
["n", 23], | |
["o", 24], | |
["p", 25], | |
["q", 26], | |
["r", 27], | |
["s", 28], | |
["t", 29], | |
["u", 30], | |
["v", 31], | |
["w", 32], | |
["x", 33], | |
["y", 34], | |
["z", 35] | |
] | |
def getValue(char): | |
for valuedChar, value in valuesList: | |
if char == valuedChar: | |
return value | |
return char | |
def toDecimal(base, x): | |
result = 0 | |
pos = 0 | |
x = x[::-1].lower() | |
for i in x: | |
if debug: | |
print( | |
"x =", getValue(i), | |
", base =", base, | |
", position =", pos, | |
", equal =", getValue(i) * base ** pos | |
) | |
result += int(getValue(i)) * base ** pos | |
pos += 1 | |
return result | |
print(toDecimal(35, "0b142zfjt")) |
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 os | |
import time | |
from gtts import gTTS | |
import pygame | |
from pygame import USEREVENT | |
from pygame import mixer | |
from pygame._sdl2 import get_num_audio_devices, get_audio_device_name | |
language = input("Language [en, ar... etc]:\n") | |
accent = input("Accent: [com.au, co.uk, com, ca, co.in, ie, co.za, ca, fr, com.br, pt, com.mx, es]:\n") | |
if accent == "": | |
accent = "com" | |
os.system("cls") | |
os.system("title Google Te1xt-to-Speech") | |
def main(): | |
mytext = input("Message: ") | |
myobj = gTTS(text=mytext, tld=accent, lang=language) | |
myobj.save("voice.mp3") | |
mixer.init(devicename="CABLE Input (VB-Audio Virtual Cable)") | |
mixer.music.load("voice.mp3") | |
mixer.music.play() | |
while mixer.music.get_busy(): | |
pass | |
mixer.music.unload() | |
os.remove("voice.mp3") | |
os.system("cls") | |
while True: | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry if it's not long enough, all of my projects are split into chunks and I prefer making clean and organized code, it's really hard for me to get good and long enough code.