This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
In this example, we're configuring Celery to use heartbeats. | |
We've set the worker_heartbeat option to 120 seconds, which means | |
that each worker will send a heartbeat message to the broker every 2 minutes. | |
This can help to ensure that tasks are not lost if a worker goes offline or crashes. | |
""" | |
from celery import Celery | |
app = Celery('tasks', broker='pyamqp://guest@localhost//') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
In this example, we're configuring Celery to prefetch 10 tasks at a time. | |
This means that each worker will load up to 10 tasks into its memory before | |
they are executed. This can help to reduce the time it takes to fetch new | |
tasks from the broker, and can improve overall performance. | |
""" | |
from celery import Celery | |
app = Celery('tasks', broker='pyamqp://guest@localhost//') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
In this example, we're configuring Celery to use threads for concurrency. | |
We've set the task_concurrency option to 4, which means that each worker | |
can handle up to 4 tasks simultaneously. We've also set the worker_prefetch_multiplier | |
option to 1, which means that each worker will only prefetch one task at a time. | |
""" | |
from celery import Celery | |
app = Celery('tasks', broker='pyamqp://guest@localhost//') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.redblobgames.com/grids/hexagons/ "double-height" horizontal layout | |
import random | |
import math | |
class Cell(): | |
""" Hexagonal cell """ | |
def __init__(self, x, y, walls=[0,1,2,3,4,5]): | |
""" x,y int | |
walls : list of number 0..5 | |
""" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import librosa | |
import numpy as np | |
import os | |
import scipy | |
import scipy.io.wavfile | |
import sys | |
from glob import glob | |
from tqdm import tqdm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pydub import AudioSegement | |
def load_audio(audio_path, ext): | |
return AudioSegement.from_file(audio_path, format=ext) | |
def speed_change(audio, speed): | |
audio_with_altered_frame_rate = audio._spawn( | |
audio.raw_data, overrides={ | |
"frame_rate": int(audio.frame_rate * speed) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python generate_spectrogram.py --audio-dir /path/to/audio_dir/ --spectrogram-dir /path/to/spectrogram_dir/ | |
import argparse | |
from __future__ import division, print_function | |
from os import listdir | |
from os.path import isfile, join | |
from matplotlib import pyplot as plt | |
import scipy.io.wavfile as wav |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder