Skip to content

Instantly share code, notes, and snippets.

import sys
from pydub import AudioSegment, silence
import numpy as np
import matplotlib.pyplot as plt
SAMPLING_RATE = 44100
THRESHOLD = 50
CONDITION_INTERVAL = 30
OFFSET = 1
import sys
from pydub import AudioSegment, silence
import numpy as np
import matplotlib.pyplot as plt
SAMPLING_RATE = 44100
# THRESHOLD = 50
# CONDITION_INTERVAL = 100
THRESHOLD = 50
CONDITION_INTERVAL = 30
#!/usr/bin/env python
import requests
import json
import base64
URL = 'http://rospeex.ucri.jgn-x.jp/nauth_json/jsServices/VoiceTraSS'
def post(text):
params = json.dumps({'method': 'speak', 'params': ['ja', text, '*', 'audio/x-wav']})
return requests.post(URL, data = params)
;;; 括弧の後のインデントが深くなるのを防ぐ
(setq ruby-deep-indent-paren-style nil)
;;; save前に行末のwhitespaceを削除
(add-hook 'before-save-hook 'delete-trailing-whitespace)
#!/bin/bash
cat $1 | while read LINE; do
echo $LINE | tr ' ' '\n' | uniq | tr '\n' ' '; echo
done
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
import numpy as np
from scipy.interpolate import interp1d
# from scipy.interpolate import UnivariateSpline
def read_csv2(data):
x = data[:, 1]
#!/usr/bin/env python
import sys
import numpy as np
import numpy.random as random
import scipy.stats as stats
import matplotlib.pyplot as plt
if __name__ == '__main__':
if len(sys.argv) < 2:
print "usage: $ ./gem_dist.py alpha"
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'pit'
require 'twitter_oauth'
def convert_row(semivowel, roman, step)
head = semivowel.unpack("U*")[0]
(0..4).map{|i| [[head + step * i].pack("U*"), roman + %w(a i u e o)[i]]}
end
#!/usr/bin/env python
import sys
import csv
import os
if __name__ == '__main__':
data = [[i if i == j else 0 for i in range(5)] for j in range(5)]
# => [[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 2, 0, 0], [0, 0, 0, 3, 0], [0, 0, 0, 0, 4]]
# dialect = 'excel'
# csv.writer(sys.stdout).writerows(data)
@phelrine
phelrine / fizzbuzz.py
Created January 18, 2012 06:29
fizz buzz
#!/usr/bin/env python
import sys
from itertools import count, cycle, izip, imap
map(sys.stdout.write, ((str(n), "Fizz", "Buzz", "FizzBuzz")[f] + "\n" for n, f in izip(count(1), imap(sum, izip(cycle((0, 0, 1)), cycle((0, 0, 0, 0, 2)))))))