| from clearvoice import ClearVoice | |
| import os | |
| # 初始化语音分离模型 | |
| cv_ss = ClearVoice( | |
| task='speech_separation', | |
| model_names=['MossFormer2_SS_16K'] | |
| ) | |
| # 处理混合语音文件 | |
| input_path = 'samples/mixed.wav' | |
| output_dir = 'samples/separated' | |
| os.makedirs(output_dir, exist_ok=True) | |
| # 分离语音并自动保存 | |
| cv_ss( | |
| input_path=input_path, | |
| online_write=True, | |
| output_path=output_dir | |
| ) | |
| # 分离后会生成多个文件: | |
| # - output_MossFormer2_SS_16K_spk1.wav | |
| # - output_MossFormer2_SS_16K_spk2.wav |