Skip to content

Instantly share code, notes, and snippets.

View ankurdhuriya's full-sized avatar
🎯
Focussing

Ankur Dhuriya ankurdhuriya

🎯
Focussing
  • ThoughtWorks
  • India
View GitHub Profile
@ankurdhuriya
ankurdhuriya / celery_heartbeats_example.py
Created March 26, 2023 16:13
Celery Heartbeats Example
"""
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//')
@ankurdhuriya
ankurdhuriya / celery_prefetching_example.py
Created March 26, 2023 16:10
Celery Prefetching Example
"""
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//')
@ankurdhuriya
ankurdhuriya / celery_concurrency_example.py
Created March 26, 2023 16:07
Celery Concurrency Example
"""
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//')
# 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
"""
@ankurdhuriya
ankurdhuriya / hifi_gan_training.ipynb
Created January 22, 2022 08:30
hifi_gan_training.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ankurdhuriya
ankurdhuriya / glow_tts_hindi_multi_speaker_training.ipynb
Created January 21, 2022 16:41
glow_tts_hindi_multi_speaker_training.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ankurdhuriya
ankurdhuriya / resample_wavs.py
Created November 20, 2021 03:30
resample wav files in paralled
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
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)
})
# 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.