mirror of
https://github.com/2noise/ChatTTS.git
synced 2026-09-01 14:55:37 +08:00
d089bd2492
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
12 lines
254 B
Python
12 lines
254 B
Python
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)
|