somefix vc
This commit is contained in:
parent
6721b81dcf
commit
92f18e2f81
@ -1,5 +1,6 @@
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
import torch
|
import torch
|
||||||
import soundfile as sf
|
import soundfile as sf
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ from infer.lib.infer_pack.models import (
|
|||||||
)
|
)
|
||||||
from infer.modules.vc.pipeline import Pipeline
|
from infer.modules.vc.pipeline import Pipeline
|
||||||
from infer.modules.vc.utils import *
|
from infer.modules.vc.utils import *
|
||||||
|
from infer.lib.audio import load_audio
|
||||||
|
|
||||||
|
|
||||||
class VC:
|
class VC:
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
import ffmpeg
|
|
||||||
from fairseq import checkpoint_utils
|
from fairseq import checkpoint_utils
|
||||||
|
|
||||||
|
|
||||||
@ -34,21 +32,3 @@ def load_hubert(config):
|
|||||||
hubert_model = hubert_model.float()
|
hubert_model = hubert_model.float()
|
||||||
return hubert_model.eval()
|
return hubert_model.eval()
|
||||||
|
|
||||||
|
|
||||||
def load_audio(file, sr):
|
|
||||||
try:
|
|
||||||
# https://github.com/openai/whisper/blob/main/whisper/audio.py#L26
|
|
||||||
# This launches a subprocess to decode audio while down-mixing and resampling as necessary.
|
|
||||||
# Requires the ffmpeg CLI and `ffmpeg-python` package to be installed.
|
|
||||||
file = (
|
|
||||||
file.strip(" ").strip('"').strip("\n").strip('"').strip(" ")
|
|
||||||
) # 防止小白拷路径头尾带了空格和"和回车
|
|
||||||
out, _ = (
|
|
||||||
ffmpeg.input(file, threads=0)
|
|
||||||
.output("-", format="f32le", acodec="pcm_f32le", ac=1, ar=sr)
|
|
||||||
.run(cmd=["ffmpeg", "-nostdin"], capture_stdout=True, capture_stderr=True)
|
|
||||||
)
|
|
||||||
except Exception as e:
|
|
||||||
raise RuntimeError(f"Failed to load audio: {e}")
|
|
||||||
|
|
||||||
return np.frombuffer(out, np.float32).flatten()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user