Skip to content

Instantly share code, notes, and snippets.

View Bentroen's full-sized avatar

Bernardo Costa Bentroen

View GitHub Profile
@Bentroen
Bentroen / async.py
Created February 10, 2021 20:33 — forked from phizaz/async.py
Python turn sync functions to async (and async to sync)
import functools
def force_async(fn):
'''
turns a sync function to async function using threads
'''
from concurrent.futures import ThreadPoolExecutor
import asyncio
pool = ThreadPoolExecutor()
@Bentroen
Bentroen / pydub_mixer.py
Last active September 2, 2021 20:55 — forked from jiaaro/pydub_mixer.py
from pydub import AudioSegment
import numpy as np
class Mixer:
def __init__(self):
self.parts = []
def __len__(self):
parts = self._sync()
seg = parts[0][1]