Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renaming files within audio-separator #128

Closed
Bebra777228 opened this issue Oct 9, 2024 · 4 comments
Closed

Renaming files within audio-separator #128

Bebra777228 opened this issue Oct 9, 2024 · 4 comments

Comments

@Bebra777228
Copy link
Contributor

I suggest improving the functionality of the audio-separator by adding two new parameters to the separate function: primary_name and secondary_name.

As a result, the code will look like this:

INPUT_PATH = "/content/input/music.mp3"
OUTPUT_PATH = "/content/output"
VOCALS = os.path.join(OUTPUT_PATH, "Vocals.wav")
INSTRUMENTAL = os.path.join(OUTPUT_PATH, "Instrumental.wav")

separator = Separator(output_dir=OUTPUT_PATH)
separator.load_model(model_filename="model_bs_roformer_ep_317_sdr_12.9755.ckpt")

voc_inst_result = separator.separate(INPUT_PATH, VOCALS, INSTRUMENTAL)

# or
voc_inst_result = separator.separate(INPUT_PATH, primary_name=VOCALS, secondary_name=INSTRUMENTAL)

If these parameters are not specified, the files will be output in the same way they are saved now.

This will be a more convenient option compared to the current approach, which requires additional file renaming:

INPUT_PATH = "/content/input/music.mp3"
OUTPUT_PATH = "/content/output"
VOCALS = os.path.join(OUTPUT_PATH, "Vocals.wav")
INSTRUMENTAL = os.path.join(OUTPUT_PATH, "Instrumental.wav")

separator = Separator(output_dir=OUTPUT_PATH)
separator.load_model(model_filename="model_bs_roformer_ep_317_sdr_12.9755.ckpt")

voc_inst_result = separator.separate(INPUT_PATH)
os.rename(os.path.join(output_dir, voc_inst_result[0]), INSTRUMENTAL)
os.rename(os.path.join(output_dir, voc_inst_result[1]), VOCALS)

Hope my idea is clear!

@beveradb
Copy link
Collaborator

beveradb commented Oct 9, 2024

Sure, fine by me if it doesn't break existing workflows - if you implement this in a PR, please add tests :)

@Bebra777228
Copy link
Contributor Author

I don't think I can do it, but I'll try :)

@StarMariner
Copy link

Q. Would the os.rename solve a problem with output-dir giving filenames with parenthesis around the stem names?
I am unable to mv or cp the filenames in an Ubuntu dash Shell script. I don't know where the parenthesis are added to the path.

audio-separator "$file" --output_dir "$output_dir" --output_format wav --single_stem vocals
Gives an output postfix of: _(Vocals)model_mel_band_roformer_ep_3005_sdr_1.wav
Filename such as : noisey_story
(Vocals)_model_mel_band_roformer_ep_3005_sdr_1.wav

@beveradb
Copy link
Collaborator

beveradb commented Nov 3, 2024

PR #141 now merged, so the new CLI parameters --primary_output_name and --secondary_output_name are available from audio-separator version 0.24 and above.

Thanks for your contribution @Bebra777228 🙇

and @StarMariner this is probably one option to help you out now, since you could specify simple output filenames with no special characters in them, e.g.
audio-separator -m UVR_MDXNET_KARA_2.onnx --primary_output_name instrumental --secondary_output_name vocals input.wav

However, if you open a discussion thread and share your shell script code, I can probably help you learn how to handle special characters properly - that's basic shell scripting stuff which you can learn on the internet pretty easily (especially with the help of LLMs these days) so you should be able to get it working 😄

@beveradb beveradb closed this as completed Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants