Skip to content

Instantly share code, notes, and snippets.

# Vaatii pip-asennukset
# sudo pip install PyAudio
# sudo pip install SpeechRecognition
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
r.adjust_for_ambient_noise(source) # Kuuntelee sekunnin ja yrittää päätellä taustamelun tason
# Blender addon sorcery
bl_info = {"name": "Audionodes", "description":"Create complex soundscapes in real time using nodes.", "author":"Roope Salmi, Théo Friberg", "version":(0,1), "blender":(2,77,0), "location":"Node Editor > Sound Icon > Add new", "warning":"Very much alpha, may blow up in your face.", "category": "Node", "tracker_url":"https://github.com/nomelif/Audionodes/issues", "wiki_url":"https://github.com/nomelif/Audionodes"}
import bpy
import numpy as np
import time
from bpy.types import NodeTree, Node, NodeSocket, NodeSocketFloat
@nomelif
nomelif / setup.py
Last active November 30, 2016 16:34
# Setup parameters to work in userspace
import sys
import os
import tempfile
import urllib.request
get_pip = urllib.request.urlopen("https://bootstrap.pypa.io/get-pip.py").read()
sys.argv.append("--user")
import pygame
import numpy as np
import time
class audioServer():
channel = None
def __init__(self):
from PIL import Image
import numpy as np
import random
w = h = 1024
data = np.zeros((h, w, 3), dtype=np.uint8)
parallellism = 2048
point = np.random.rand(parallellism).reshape((parallellism//2,2))
from PIL import Image
import numpy as np
import random
from multiprocessing import Pool
def f(taajuus):
w = (512 * np.sqrt(3))*2
h = (512 + np.sqrt(3)*128)*2
data = np.zeros((h, w, 3)).astype(np.float32)
import pygame
import numpy as np
def eventGenerator(eventcode, bufferSize): # Event loop; wait while PyGame is OK, yield to the signal generator when pygame asks for signal
# Buffer
for chunk in range(bufferSize):
@nomelif
nomelif / Midify.py
Created January 8, 2017 18:19
This transforms microphone input into MIDI data in real time and spits it over ALSA.
import pyaudio
import alsaseq
import numpy as np
CHUNKSIZE = 1024*2 # fixed chunk size
# initialize portaudio
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paInt16, channels=1, rate=44100, input=True, frames_per_buffer=CHUNKSIZE)
@nomelif
nomelif / rooliarpoja.py
Last active January 25, 2017 06:30
susirunko.py
# WSGI:n perus kirjasto
from wsgiref.simple_server import make_server
# Tätä funktiota kutsutaan aina, kun selain haluaa sivun
# environ: yleistä tietoutta: mitä sivua kysyttiin, millainen vempain jne jne jne
# start_response: funktio, jolla kerrotaan WSGIlle palautetun kaman tyyppi ja mahdolliset virheet
ilmoittautuneet = []
@nomelif
nomelif / voicemod.py
Created March 20, 2017 15:40
Skeleton for on-line voice modification scripts. Requires numpy and PyAudio
import pyaudio
import numpy as np
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 44100
CHUNK = 1024
audio = pyaudio.PyAudio()