Skip to content

Instantly share code, notes, and snippets.

View baali's full-sized avatar
🏠
Working from home

baali baali

🏠
Working from home
View GitHub Profile
@baali
baali / dlAttachments.py
Created May 8, 2012 08:32
Python script to download all gmail attachments.
# Something in lines of http://stackoverflow.com/questions/348630/how-can-i-download-all-emails-with-attachments-from-gmail
# Make sure you have IMAP enabled in your gmail settings.
# Right now it won't download same file name twice even if their contents are different.
import email
import getpass, imaplib
import os
import sys
detach_dir = '.'
@baali
baali / audio.html
Created May 4, 2012 17:20
chrome api for speech recognition
<!DOCTYPE html>
<html manifest="cache.appcache">
<head>Speech Recognition</head>
<body>
<input type="text" x-webkit-speech />
</body>
</html>
@baali
baali / permute_list.erl
Created April 10, 2012 08:05
Permutation of List in Erlang
-module('permute_list').
-export([permute/1, permute/2]).
permute(List) ->
permute(List, length(List)).
permute(List, Length) ->
Indices = [],
Permuted_List = [],
jumble(List, Permuted_List, Indices, Length).
@baali
baali / manual_nltk_bayes_classify.py
Created December 15, 2011 07:12 — forked from lrvick/manual_nltk_bayes_classify.py
Manually train an NLTK NaiveBayes Classifier
from nltk.probability import ELEProbDist, FreqDist
from nltk import NaiveBayesClassifier
from collections import defaultdict
train_samples = {
'I hate you and you are a bad person': 'neg',
'I love you and you are a good person': 'pos',
'I fail at everything and I want to kill people' : 'neg',
'I win at everything and I want to love people' : 'pos',
'sad are things are heppening. fml' : 'neg',
@baali
baali / speech2text.py
Created December 6, 2011 04:03
A Python script to break audio into chunks of smaller audios and using Google API to get Speech to Text.
'''
A hack based on this http://mikepultz.com/2011/03/accessing-google-speech-api-chrome-11/. While with smaller voice samples google speech to text works really good, as length increases quality decreases. So here using audiolab and numPy we are breaking audio sample, in smaller chunks, and removing blank/empty spaces from audio signal and then pushing them to google for processing.
It takes wav file format as input but can be changed to other formats too.
'''
from scikits.audiolab import wavread, play, flacwrite
from numpy import average, array, hstack
import os
import sys