s2s / utils /utils.py
andito's picture
andito HF staff
Upload folder using huggingface_hub
c72e80d verified
raw
history blame contribute delete
383 Bytes
import numpy as np
def next_power_of_2(x):
return 1 if x == 0 else 2 ** (x - 1).bit_length()
def int2float(sound):
"""
Taken from https://github.com/snakers4/silero-vad
"""
abs_max = np.abs(sound).max()
sound = sound.astype("float32")
if abs_max > 0:
sound *= 1 / 32768
sound = sound.squeeze() # depends on the use case
return sound