""" This example bot will demonstrate two things: - annotations that include no tags and only represent a segmentation - a bot that does not use zounds to compute features """ import librosa from bot_helper import main, SoundListener from log import module_logger import zounds import requests from io import BytesIO import numpy as np logger = module_logger(__file__) class OnsetListener(SoundListener): def __init__(self, client, s3_client, page_size=3, logger=None): super().__init__(client, s3_client, page_size, logger) def get_metadata(self): return {} def _process_sound(self, sound): # fetch audio resp = requests.get(sound['audio_url']) raw_audio = BytesIO(resp.content) # Convert to mono samples = zounds.AudioSamples.from_file(raw_audio)
# -*- coding: utf-8 -*- import os import boto,psycopg2 from boto.s3.key import Key import log,ctrl,util logger = log.module_logger() def s3conn(): conn = boto.connect_s3() return conn def get_bucket(conn,bucketname): bucket = conn.get_bucket(bucketname) return bucket def set_contents(bucket,localfile): key = Key(bucket,localfile.name) res = key.set_contents_from_file(localfile) return res def get_contents(bucket,filename,localpath): key = bucket.get_key(filename) if key is None: raise SystemError('{0} in s3 bucket {1} not found.'.format(filename,str(bucket))) filepath = os.path.join(localpath,filename) key.get_contents_to_filename(filepath) return os.path.isfile(filepath) def rdsconn(config):