update example code for each preprocess module

This commit is contained in:
jlqian98
2026-03-04 15:02:34 +08:00
parent 79e1f06d7d
commit 7bc2dfea6e
5 changed files with 36 additions and 23 deletions
+3 -3
View File
@@ -516,12 +516,12 @@ class F0Extractor:
if __name__ == "__main__":
model_path = (
"pretrained_models/rmvpe/rmvpe.pt"
"pretrained_models/SoulX-Singer-Preprocess/rmvpe/rmvpe.pt"
)
audio_path = "./outputs/transcription/test.wav"
audio_path = "example/audio/zh_prompt.mp3"
pe = F0Extractor(
model_path,
device="cuda",
)
f0 = pe.process(audio_path)
f0 = pe.process(audio_path, f0_path="example/audio/zh_prompt_f0.npy")
+13 -9
View File
@@ -120,9 +120,10 @@ class _ASRZhModel:
raw_timestamps = [[t[0] / 1000, t[1] / 1000] for t in out["timestamp"]]
words, word_durs = _build_words_with_gaps(raw_words, raw_timestamps, wav_fn)
if os.path.exists(wav_fn.replace(".wav", "_f0.npy")):
f0_path = os.path.splitext(wav_fn)[0] + "_f0.npy"
if os.path.exists(f0_path):
words, word_durs = _word_dur_post_process(
words, word_durs, np.load(wav_fn.replace(".wav", "_f0.npy"))
words, word_durs, np.load(f0_path)
)
return words, word_durs
@@ -179,9 +180,10 @@ class _ASREnModel:
words, durs = _build_words_with_gaps(raw_words, raw_timestamps, wav_fn)
if os.path.exists(wav_fn.replace(".wav", "_f0.npy")):
f0_path = os.path.splitext(wav_fn)[0] + "_f0.npy"
if os.path.exists(f0_path):
words, durs = _word_dur_post_process(
words, durs, np.load(wav_fn.replace(".wav", "_f0.npy"))
words, durs, np.load(f0_path)
)
return words, durs
@@ -248,8 +250,10 @@ class LyricTranscriber:
if self.en_model is None:
# Lazy-load NeMo model only when English is actually used.
if v:
print("[lyric transcription] init English ASR, please make sure NeMo is installed")
print("[lyric transcription] init English ASR start, please make sure NeMo is installed and wait for a while")
self.en_model = _ASREnModel(model_path=self.en_model_path, device=self.device)
if v:
print("[lyric transcription] init English ASR success")
out = self.en_model.process(wav_fn)
else:
out = self.zh_model.process(wav_fn)
@@ -271,9 +275,9 @@ class LyricTranscriber:
if __name__ == "__main__":
m = LyricTranscriber(
zh_model_path="pretrained_models/speech_seaco_paraformer_large_asr_nat-zh-cn-16k-common-vocab8404-pytorch",
en_model_path="pretrained_models/parakeet-tdt-0.6b-v2/parakeet-tdt-0.6b-v2.nemo",
zh_model_path="pretrained_models/SoulX-Singer-Preprocess/speech_seaco_paraformer_large_asr_nat-zh-cn-16k-common-vocab8404-pytorch",
en_model_path="pretrained_models/SoulX-Singer-Preprocess/parakeet-tdt-0.6b-v2/parakeet-tdt-0.6b-v2.nemo",
device="cuda"
)
print(m.process("example/test/asr_zh.wav", language="Mandarin"))
print(m.process("example/test/asr_en.wav", language="English"))
print(m.process("example/audio/zh_prompt.mp3", language="Mandarin"))
print(m.process("example/audio/en_prompt.mp3", language="English"))
+14 -5
View File
@@ -509,14 +509,23 @@ class NoteTranscriber:
if __name__ == "__main__":
items = json.load(open("example/test/rosvot_input.json", "r"))
item = items[0]
item = {
'item_name': 'vocal_0',
'wav_fn': 'example/audio/zh_prompt.mp3',
'start_time_ms': 320,
'end_time_ms': 10687,
'origin_wav_fn': 'example/audio/zh_prompt.mp3',
'duration': 10367,
'words': ['<SP>', '除', '了', '想', '你', '<SP>', '除', '了', '爱', '你', '<SP>', '我', '什', '么', '什', '么', '都', '愿', '意'],
'word_durs': [0.21, 0.36, 0.26, 0.7000000000000001, 0.96, 0.3800000000000001, 0.43999999999999995, 0.3799999999999999, 0.6400000000000001, 0.9600000000000002, 1.1199999999999999, 0.28000000000000025, 0.3799999999999999, 0.3199999999999994, 0.3200000000000003, 0.3799999999999999, 0.3200000000000003, 0.5, 1.457981859410431],
'language': 'Mandarin'
}
m = NoteTranscriber(
rosvot_model_path="pretrained_models/rosvot/rosvot/model.pt",
rwbd_model_path="pretrained_models/rosvot/rwbd/model.pt",
rosvot_model_path="pretrained_models/SoulX-Singer-Preprocess/rosvot/rosvot/model.pt",
rwbd_model_path="pretrained_models/SoulX-Singer-Preprocess/rosvot/rwbd/model.pt",
device="cuda"
)
out = m.process(item)
out = m.process(item, segment_info=item)
print(out)
+1 -1
View File
@@ -316,5 +316,5 @@ class VocalDetector:
if __name__ == "__main__":
m = VocalDetector(cut_wavs_output_dir="outputs/transcription/cut_wavs")
segment_infos = m.process("./outputs/transcription/test.wav")
segment_infos = m.process("example/audio/zh_prompt.mp3", np.load("example/audio/zh_prompt_f0.npy"))
print(segment_infos)
+5 -5
View File
@@ -214,12 +214,12 @@ class VocalSeparator:
if __name__ == "__main__":
m = VocalSeparator(
sep_model_path="pretrained_models/mel-band-roformer-karaoke/mel_band_roformer_karaoke_becruily.ckpt",
sep_config_path="pretrained_models/mel-band-roformer-karaoke/config_karaoke_becruily.yaml",
der_model_path="pretrained_models/dereverb_mel_band_roformer/dereverb_mel_band_roformer_anvuew_sdr_19.1729.ckpt",
der_config_path="pretrained_models/dereverb_mel_band_roformer/dereverb_mel_band_roformer_anvuew.yaml",
sep_model_path="pretrained_models/SoulX-Singer-Preprocess/mel-band-roformer-karaoke/mel_band_roformer_karaoke_becruily.ckpt",
sep_config_path="pretrained_models/SoulX-Singer-Preprocess/mel-band-roformer-karaoke/config_karaoke_becruily.yaml",
der_model_path="pretrained_models/SoulX-Singer-Preprocess/dereverb_mel_band_roformer/dereverb_mel_band_roformer_anvuew_sdr_19.1729.ckpt",
der_config_path="pretrained_models/SoulX-Singer-Preprocess/dereverb_mel_band_roformer/dereverb_mel_band_roformer_anvuew.yaml",
device="cuda"
)
out = m.process("example/test/separation_test.mp3")
out = m.process("example/audio/zh_prompt.mp3")
print(out.vocals_dereverbed.shape)