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

[feature] add EnCodec model embeddings to FAD calculation #23

Merged
merged 5 commits into from
Nov 20, 2023

Conversation

ivanlmh
Copy link
Contributor

@ivanlmh ivanlmh commented Nov 16, 2023

Hi Hao Hao, I've added Meta's EnCodec model (the 2 main versions they offer pre-trained) for FAD calculation

  • [feature] add EnCodec to available models
  • [test] add 24khz and 48khz models' test to test_all notebook
  • [update] requirements

Let me know if there is something you think should be fixed or whatever :)

@@ -32,7 +34,8 @@ def load_audio_task(fname, sample_rate, dtype="float32"):
wav_data = wav_data / float(2**31)

# Convert to mono
if len(wav_data.shape) > 1:
assert channels in [1, 2], "channels must be 1 or 2"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

channels here is unspecified, I guess you miss a line before this to calculatechannels from wav_data

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's fixed now. It's an input to the function, defaulting to 1 unless specified (as should be done for encodec 48khz)

@@ -309,8 +360,8 @@ def update(*a):
for fname in os.listdir(dir):
res = pool.apply_async(
load_audio_task,
args=(os.path.join(dir, fname), self.sample_rate, dtype),
callback=update
args=(os.path.join(dir, fname), self.sample_rate, self.channels, dtype),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect self.channels is not defined here, but please correct me if I am wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, it looks like I erased the definition when commiting

@gudgud96
Copy link
Owner

gudgud96 commented Nov 16, 2023

@ivanlmh Huge thanks to you contribution! Encodec is a very useful one.
Minor comments related to undefined variables.

@ivanlmh
Copy link
Contributor Author

ivanlmh commented Nov 17, 2023

I think that's fixed... idk why the definitions disappeared, but anyway :)

@gudgud96 gudgud96 merged commit cf50298 into gudgud96:main Nov 20, 2023
1 check passed
@gudgud96
Copy link
Owner

@ivanlmh Merged, huge thanks for your contribution once again!

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

Successfully merging this pull request may close these issues.

2 participants