benfmiller/audalign

I know very little about coding. I never really used GitHub that much.

Cowboyhebert6 opened this issue · 52 comments

Is there a way someone that can do this process of aligning two audio files I have, without me having to do it using this command program (audalign)?

You mean you want a program with a graphic interface? El vie., 31 de marzo de 2023 1:02, Cowboyhebert6 @.***> escribió:

Yeah something like that? because I know absolutely nothing on where to put the files within the code and what code is used for audalign in order to actually align the fils I have within adobe audition, that's my issue? I'm confused on how it all works and I need a little bit of guidance generally.

Yeah I kind of am Are u able to help on where I should put the audio files within the Audalign command that’s what I’m confused on. @EGA-SUPREMO

I think aligning audio can be done somewhere in Adobe Audition or Audacity, but either way if you want to use this program you would need to:

Install Python 3
Install FFmpeg

after that, you would need to open Powershell(can be done by pressing Win + R and then putting 'powershell' without quotes)
and run:
pip install audalign

I can give you instructions on how to install Python and FFpmeg in case you don't have installed if you want

then you need to create a file, for example name it corr.py and paste this code:

import audalign as ad

def align_folder():
    correlation_rec = ad.CorrelationRecognizer()

    results = ad.align_files(
        "target/file1",
        "target/file2",
        destination_path="write/alignments/to/folder",
        recognizer=correlation_rec
    )
    return results

if __name__ == "__main__":
    results = align_folder()

In summary, this code aligns two audio files using the specified algorithm and saves the aligned segments to a new folder. You would need to change "target/file1", "target/file2" and "write/alignments/to/folder" into the directory you have the audios.

But if you want to just align two files, I would recommend to just use Audacity or Adobe Audition, as it will take less time to set up and configure, this program is useful if you have a large amount of audios to the point it will be a pain to open, align and then save it each one of them

@EGA-SUPREMO yes plz absolutely also, if your able to help on what to type can u demonstrate that too like physically what to type into the audalign program as well?

Do you have python installed?

@EGA-SUPREMO oops sorry I didn’t see your message until now yes I did install it yes

How do I use it with audition though I never knew it was able to be compatible? @EGA-SUPREMO

@EGA-SUPREMO also, how do u open the audalign in adobe audition? That’s what I’m mainly trying to figure out which I never have knew it was possible?

Are u there still? @EGA-SUPREMO

yes, I'm thinking what to reply

@EGA-SUPREMO also, how do u open the audalign in adobe audition? That’s what I’m mainly trying to figure out which I never have knew it was possible?

I don't think that is possible, either way, did you manage to install audalign?

@EGA-SUPREMO I got python installed, but now audalign because the code part “pip install audalign” seems to give me an error?

what error?

@EGA-SUPREMO That's the error?

I really don't know, maybe PATH was not set up correctly or a Python installation issue

Well how do I setup the path for this part in order to make it work?

image
what about this error?

pip is meant to be run on the command line, not as a python code

Those steps may differ from environment from environment, but to add PATH to pip:

Open the Start menu and search for "Environment Variables". Click on "Edit the system environment variables" from the results.

In the System Properties window, click on the "Environment Variables" button.

In the Environment Variables window, find the "Path" variable in the "System variables" section and click on "Edit".

Click on "New" and add the path to the Python scripts folder. By default, the scripts folder is located in the following path: C:\PythonXX\Scripts, where XX is the version of Python you have installed (e.g., 37 for Python 3.7).

Click "OK" to close all windows and save the changes.

I don't know anything about your environment or how did you install Python, I think it may be more efficient that you look on how to run pip through the command line, I can help you with running audalign.

StackOverflow and ChatGPT can be of great help

@EGA-SUPREMO Okay but, you said that the PowerShell was the main program that i should use correct?

@EGA-SUPREMO Also, did you mean can help or can't help I know I've made so many comment? sorry.

Mainly I'm curious if i need to type the file names manually into the program in order for it to perform?
@EGA-SUPREMO

@EGA-SUPREMO Okay but, you said that the PowerShell was the main program that i should use correct?

Yes

@EGA-SUPREMO Also, did you mean can help or can't help I know I've made so many comment? sorry.

Sorry, I don't understand

Mainly I'm curious if i need to type the file names manually into the program in order for it to perform?

With the script I passed, yes, but I can change it if you want to write only the folder

Yes plz you can write the folder? Also, Be aware though my main situation is I'm trying to align 2 music files for an old guitar solo song (free bird by lynyrd skynyrd) along with the a vocal track that has not music from the song in order to do that i thought this command would help so that way i can invert just the vocal track since's it will already be in time with other file which is the full song?

That would be sooooo much easier thank you. I'm actually still learning how to use github so this is my first time using it, thanks so much for your help and your hard work man. @EGA-SUPREMO

If you don't mind which I reeeeally would prefer, but are you able to do the file aligning process for me instead of me having to do it by myself? Since I don't know too much on how to use it still with all errors I've came across? I'm aligning 2 audio files for a song free bird by Lynyrd Skynyrd using this command line program, one is just the vocals ( in Stereo) all by themselves and the other is the entire song (in Stereo).
@EGA-SUPREMO

sure give me the link to download the audios

@EGA-SUPREMO Okay great thanks buddy here they are. Keep in mind there they are waaaaay out of sync. let me know when your finsihed and send the folder of the aligned files to me through a zip to my email, “amcqueen2004@gmail.com
Thanks man

Vocals.zip
Free Bird (Extended Music Version).zip

Turn out, this program doesn't work for those kind of files. It only works if the audios are nearly identical, like for example, a concert recorded by two different microphones, but not to align music with vocals

@EGA-SUPREMO Okay, I have similar that's actually a little bit easier I'm going to send you another batch of the same song but they will both be similar but will sound identical but it will be and instrumental version of the other song exact same song will you try that instead? is that okay?

@EGA-SUPREMO I'll send them both tomorrow so you can try this process again but with different files?

Yeah, I can try and as long as the sound is nearly identical it will work.

Thanks for helping @EGA-SUPREMO!

I don't think adobe audition has any support for that kind of plugin. I only used adobe audition as a way to illustrate the alignment of the files after they were aligned by audalign, sorry for the confusion.

If python is installed but pip isn't on windows, this command might work to install pip?

 py -m ensurepip --upgrade

Audalign is a python library, so you can use pip to install audalign and create a python file like the one provided by @EGA-SUPREMO above, which can then be run from powershell with python python-file.py.

The recordings to align would ideally be of the exact same event, but could work if the sounds in the recordings are similar enough. The two main recognizers in audalign use either correlation or fingerprinting. Correlation works by multiplying the number values of the audio files together with all possible alignments and finding the offset that has the highest sum, or similarity. Fingerprinting works by matching exact "fingerprints", or combinations of two or three peak frequencies from the spectrogram of each file. Correlation works better with longer segments that can be less similar, and fingerprinting works better with shorter segments that have the same frequency peaks and are more similar. There is some more information on how the recognizers work in the wiki.

@benfmiller Hi Ben how u doing it’s so good to hear from you I just now saw your message, I know kind of to a certain extent of understand what your talking about, but mainly all what I want is if u possibly could as a favor for me to just simply use this command or code whatever it is because to be honest “I know nothing about coding at all really”, but I was wondering as a favor if u could just use audalign “unless if it wasn’t made for vocals to be aligned with the full song” if u could do is just align it for me without me having to use it and do it by myself?

@benfmiller i don’t know if u still remember how to use audalign in case is why I was asking. Thanks for your help too man if u can try to use audalign for those too file I sent to @EGA-SUPREMO within these comments since I don’t know what to physically put and where it should be.

thanks for helping me guys.

@benfmiller @EGA-SUPREMO I’ve gotta head to work tonight, but I’ll respond and reach out tomorrow to y’all in this chat thanks guys

Sincerely,
Cowboyhebert6

For sure! It probably would have been easier to visually do it in Adobe Audition, but audalign worked just fine with those two files.

import audalign as ad

fingerprint_recognizer = ad.FingerprintRecognizer()
fingerprint_recognizer.config.set_accuracy(4)
result = ad.align("audio_files/cowboyhebert6-issue48")
correlation_recognizer = ad.CorrelationRecognizer()
result = ad.fine_align(
    result,
    recognizer=correlation_recognizer,
)
ad.pretty_print_results(result)
ad.write_shifts_from_results(result, "audio_files/shifts", unprocessed=True)

Free Bird (extended Music Version).zip (shifted)
output.txt

Where's the Vocal file? @benfmiller

Can you get the vocal file sent to me too? Since it was included? @benfmiller

You got the Vocals.mp3 File that's aligned already? @benfmiller

@benfmiller You forgot to send me the shifted Vocals file?

The vocals file wasn't changed, so I didn't resend it @Cowboyhebert6

But its says in the code the shift was made can you send back it just in case al least? because I saw I thought said was shifted and edited in the the output text file? @benfmiller

it says it written the file right here is why I was asking? @benfmiller
Screen Shot 2023-04-05 at 8 56 38 PM

@benfmiller I was curious to find out since that part of the code made multiple files from the aligning process?

@benfmiller I sent some messages yesterday evening I didn't know if you gotten them yet to be honest? I sent a picture of part of the code from the output.txt file and asked why did it say it written 2 other files?

Sure! Here are the files

The output shows the offsets at line 76

Free Bird (Extended Music Version).mp3 : 3.79032
Vocals.mp3 : 0.0

So 3.79032 seconds were added to the start of the FreeBird.mp3, and 0 seconds were added to the start of Vocals.mp3. Total.m4a contains both files written to one audio file.

Vocals.mp3.zip
total.m4a.zip