Spaces:
Paused
Paused
2504 unmodified lines2505250625072508250925102504 unmodified lines)def _render_step_5(total_config: TotalConfig,tab_config: MultiStepSongGenerationConfig,2504 unmodified lines250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902504 unmodified lines)def separate_audio(audio_track: StrPath,song_dir: StrPath,model_name: SeparationModel,segment_size: int,) -> tuple[Path, Path]:"""Separate an audio track into a primary stem and a secondary stem.Parameters----------audio_track : StrPathThe path to the audio track to separate.song_dir : StrPathThe path to the song directory where the separated primary stemand secondary stem will be saved.model_name : strThe name of the model to use for audio separation.segment_size : intThe segment size to use for audio separation.Returns-------primary_path : PathThe path to the separated primary stem.secondary_path : PathThe path to the separated secondary stem."""audio_path = validate_audio_file_exists(audio_track, Entity.AUDIO_TRACK)song_dir_path = validate_audio_dir_exists(song_dir, Entity.SONG_DIR)args_dict = SeparatedAudioMetaData(audio_track=FileMetaData(name=audio_path.name,hash_id=get_file_hash(audio_path),),model_name=model_name,segment_size=segment_size,).model_dump()paths = [get_unique_base_path(song_dir_path,prefix,args_dict,).with_suffix(suffix)for prefix in ["11_Stem_Primary", "11_Stem_Secondary"]for suffix in [".wav", ".json"]](primary_path,primary_json_path,secondary_path,secondary_json_path,) = pathsif not all(path.exists() for path in paths):audio_separator = _get_audio_separator(output_dir=song_dir_path,segment_size=segment_size,)audio_separator.load_model(model_name)audio_separator.separate(str(audio_path),custom_output_names={audio_separator.model_instance.primary_stem_name: str(primary_path.with_suffix(""),),audio_separator.model_instance.secondary_stem_name: str(secondary_path.with_suffix(""),),},)json_dump(args_dict, primary_json_path)json_dump(args_dict, secondary_json_path)return primary_path, secondary_pathdef _render_step_5(total_config: TotalConfig,tab_config: MultiStepSongGenerationConfig,
app.py+80