zhengr's picture
init
c02bdcd
raw
history blame contribute delete
254 Bytes
import math
import numpy as np
from numba import jit
@jit
def float_to_int16(audio: np.ndarray) -> np.ndarray:
am = int(math.ceil(float(np.abs(audio).max())) * 32768)
am = 32767 * 32768 // am
return np.multiply(audio, am).astype(np.int16)