import math | |
import numpy as np | |
from numba import 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) | |
import math | |
import numpy as np | |
from numba import 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) | |