Skip to content

Instantly share code, notes, and snippets.

View nkpro2000sr's full-sized avatar
🤔
Developing my project

NAVEEN S R nkpro2000sr

🤔
Developing my project
View GitHub Profile
@nkpro2000sr
nkpro2000sr / plot_multiline_graph.py
Last active February 2, 2020 08:34
this is to plot multiline graph using given plot.csv file (a line for each labels)
import csv
# input data is "plot.csv" file
## with first column as lable and (second, third) as (x, y)
"""sample
labels | x_label | y_label
--------------------------
label_1| 1 | 2
label_1| 2 | 3
label_1| 3 | 4
label_2| 1 | 1
#nkpro REPLinJulia
println("Julia-v 1.0.0")
while true
print("\n>")
expr = readline()
if expr == "exit"
break
end
eval(Meta.parse(expr))
end
@nkpro2000sr
nkpro2000sr / n2wd.py
Last active February 16, 2020 18:33
number to word #just_for_fun_:-) comment your efficient code
ones = ['<0>',"one","two","three","four","five","six","seven","eight","nine"]
tens = ['','<Teenify>',"twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"]
def Teenify(num):
num[1]=''
if num[0]=="<0>":num[0]="ten"
elif num[0]=="one":num[0]="eleven"
elif num[0]=="two":num[0]="twelve"
elif num[0]=="three":num[0]="thirteen"
elif num[0]=="five":num[0]="fifteen"
@nkpro2000sr
nkpro2000sr / say_gtts.py
Created February 8, 2020 07:19
text_to_speech you can hear speech by calling say("text")
from gtts import gTTS
from io import BytesIO
import pygame; pygame.mixer.init()
def say(text):
tts = gTTS(text=text, lang='en')
fp = BytesIO()
tts.write_to_fp(fp)
fp.seek(0)
pygame.mixer.music.load(fp)
@nkpro2000sr
nkpro2000sr / change_duration.py
Last active February 16, 2020 18:35
To change dueration of audio file. we can also generate different voices with changing dueration and frame_rate.
from pydub import AudioSegment as As
import os
def change(p_af, p_maf, duer, fr= None) :
"""$p_af is path of input audio file
$p_maf is path for output audio file
$duer = output audio file duration (in seconds)
$fr = output audio file frame rate"""
with open(p_af, 'rb') as af :
sound = As.from_file(af)
@nkpro2000sr
nkpro2000sr / audplt.py
Last active February 21, 2020 07:01
plot audio file in matplotlib
from matplotlib import pyplot as plt
import librosa
#For specgram
NFFT = 1024
noverlap = 900
#For MFCC
n_mfcc = 40
@nkpro2000sr
nkpro2000sr / script.js
Last active February 21, 2020 07:03
how to load another js script from js script
var url = "url_of_another_js"
document.write('<script src="'.concat(url,'"></script>'))
@nkpro2000sr
nkpro2000sr / DataGenerator.py
Last active February 24, 2020 17:25
To generate batches for training DeepLearning model from a dataset.
import os, random, numpy
def getPathALables(p_TDS, p_VDS =None):
"""
$p_TDS = path of training data set
$p_VDS = path of validation data set
$return[0] = All_labels
$return[1][0] = paths of files in training data set
$return[1][1] = one hot encoded lables for $return[1][0]
$rerurn[2] is same as $return[1] for validation data set
@nkpro2000sr
nkpro2000sr / buildozer_docker.sh
Last active March 1, 2020 04:38
to build apk using python-kivy-buildozer (it starts with bash)
dockerd &>/dev/null &
echo -n "waiting for docker daemon to start ..."
o="$(sudo docker images 2>/dev/null)"
l=`expr length "$o"`
while [ $l -eq 0 ]
do
sleep 0.5
echo -n '.'
o="$(sudo docker images 2>/dev/null)"
l=`expr length "$o"`
@nkpro2000sr
nkpro2000sr / free_server.py
Last active March 20, 2020 05:28
host free server using python anywhere. but only one port ("user_name.pythonanywhere.com",80)
import requests # only these [urls](www.pythonanywhere.com/whitelist/) are allowed
def get_content(path):
" Do whatever with `path` and generate `content` "
return content
def application(environ, start_response):
path = environ.get('PATH_INFO')
content = get_content(path)
if content == None :
status = '404 NOT FOUND'