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

fix(audio): fix loading for UVR

wrapped gathering of META info from the stream into a function

fixes loading for UVR
This commit is contained in:
Alex Murkoff
2024-06-11 14:45:31 +07:00
parent 858daa5620
commit 60d33c249b
2 changed files with 20 additions and 13 deletions

View File

@@ -4,8 +4,7 @@ import logging
logger = logging.getLogger(__name__)
import av
from infer.lib.audio import resample_audio
from infer.lib.audio import resample_audio, get_audio_properties
import torch
from configs import Config
@@ -47,11 +46,10 @@ def uvr(model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format
need_reformat = 1
done = 0
try:
container = av.open(inp_path)
audio_stream = next(s for s in container.streams if s.type == 'audio')
channels, rate = get_audio_properties(inp_path)
# Check the audio stream's properties
if audio_stream.channels == 2 and audio_stream.rate == 44100:
if channels == 2 and rate == 44100:
pre_fun._path_audio_(inp_path, save_root_ins, save_root_vocal, format0, is_hp3=is_hp3)
need_reformat = 0
done = 1
@@ -63,7 +61,7 @@ def uvr(model_name, inp_root, save_root_vocal, paths, save_root_ins, agg, format
os.path.join(os.environ["TEMP"]),
os.path.basename(inp_path),
)
resample_audio(inp_path, tmp_path, 'pcm_s16le', 44100, 'stereo')
resample_audio(inp_path, tmp_path, 'pcm_s16le', 's16', 44100, 'stereo')
inp_path = tmp_path
try:
if done == 0: