RVC-Project / Retrieval-based-Voice-Conversion-WebUI

Easily train a good VC model with voice data <= 10 mins!
MIT License
24.76k stars 3.63k forks source link

Can't convert with external audios. #2348

Open Pyloupy opened 1 month ago

Pyloupy commented 1 month ago

Hi, Firstly thanks if you read this and you can help me. I don't know why, but with my models that i trained i can only convert audio recording from audacity. When i try to use a downloaded audio like youtube mp3 or even with obs and then converted by audacity it just doesnt work and get me an error after excatly 5.6s each time. I did multiples fresh installation with multiples python versions (3.10 and 3.9). The thing is that i've got no error in the console so im hopeless. here's some screenshots so you can understand better. Capture d'écran 2024-10-14 234507 Capture d'écran 2024-10-14 234514 Capture d'écran 2024-10-14 234531 Thank you in advance if you can help me!

mozz85 commented 3 weeks ago

"get me an error after excatly 5.6s each time."

I got the same problem. and I don't know why.

mozz85 commented 3 weeks ago

I added some prints. it looks like this 批注 2024-10-29 213859

mozz85 commented 3 weeks ago

probably something wrong with the gradio

You can save the audio after voice conversion by adding this line of code sf.write('/where/you/want/to/save/xxx.wav', audio_opt, tgt_sr) at here right before vc_single(infer/modules/vc/modules.py:146) return

    def vc_single(
        self,
        sid,
        input_audio_path,
        f0_up_key,
        f0_file,
        f0_method,
        file_index,
        file_index2,
        index_rate,
        filter_radius,
        resample_sr,
        rms_mix_rate,
        protect,
    ):
        # print('vc_single start | modules.py:161')
        if input_audio_path is None:
            return "You need to upload an audio", None
        f0_up_key = int(f0_up_key)
        try:
            audio = load_audio(input_audio_path, 16000)
            audio_max = np.abs(audio).max() / 0.95
            if audio_max > 1:
                audio /= audio_max
            times = [0, 0, 0]

            if self.hubert_model is None:
                self.hubert_model = load_hubert(self.config)

            if file_index:
                file_index = (
                    file_index.strip(" ")
                    .strip('"')
                    .strip("\n")
                    .strip('"')
                    .strip(" ")
                    .replace("trained", "added")
                )
            elif file_index2:
                file_index = file_index2
            else:
                file_index = ""  # 防止小白写错,自动帮他替换掉

            audio_opt = self.pipeline.pipeline(
                self.hubert_model,
                self.net_g,
                sid,
                audio,
                input_audio_path,
                times,
                f0_up_key,
                f0_method,
                file_index,
                index_rate,
                self.if_f0,
                filter_radius,
                self.tgt_sr,
                resample_sr,
                rms_mix_rate,
                self.version,
                protect,
                f0_file,
            )
            if self.tgt_sr != resample_sr >= 16000:
                tgt_sr = resample_sr
            else:
                tgt_sr = self.tgt_sr
            index_info = (
                "Index:\n%s." % file_index
                if os.path.exists(file_index)
                else "Index not used."
            )

            sf.write('E:\素材库\视频素材库\RVC_output.wav', audio_opt, tgt_sr)  ##### ADD IT HERE #####

            return (
                "Success.\n%s\nTime:\nnpy: %.2fs, f0: %.2fs, infer: %.2fs."
                % (index_info, *times),
                (tgt_sr, audio_opt),
            )
        except:
            info = traceback.format_exc()
            logger.warning(info)
            return info, (None, None)

save it then restart the RVC try it again. you will still get the error on web but this time, check /where/you/want/to/save/xxx.wav. it will be there waiting for you to play

mozz85 commented 3 weeks ago

found a better solution. #2355 It worked