1
0
mirror of https://github.com/fumiama/Retrieval-based-Voice-Conversion-WebUI.git synced 2026-06-05 09:10:25 +08:00

feat(audio): pre-allocate decoded_audio array in the load_audio function

this should improve performance, even if just a little
This commit is contained in:
Alex Murkoff
2024-06-11 16:23:13 +07:00
parent 68a3d8caf2
commit 2574ce5ea2

View File

@@ -42,7 +42,9 @@ def load_audio(file: str, sr: int) -> np.ndarray:
try:
container = av.open(file)
resampler = AudioResampler(format='fltp', layout='mono', rate=sr)
decoded_audio = []
# AV stores duration in nanoseconds
decoded_audio = (((container.duration * sr / container.bit_rate) // 1_000_000) + 1)*[]
for frame in container.decode(audio=0):
frame.pts = None # Clear presentation timestamp to avoid resampling issues