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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user