-
Notifications
You must be signed in to change notification settings - Fork 0
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
refactor!: change model to expect mel-band oriented tensors instead of time-oriented ones #39
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make the code a little bit more readable
if time_oriented: | ||
data = data.transpose(0, 1) | ||
data_size = data.size() | ||
if ( | ||
checkpoint["hyper_parameters"]["config"]["preprocessing"]["audio"]["n_mels"] | ||
not in data_size | ||
): | ||
raise ValueError( | ||
f"Your model expects a spectrogram of dimensions [K (Mel bands), T (frames)] where K == {checkpoint['hyper_parameters']['config']['preprocessing']['audio']['n_mels']} but you provided a tensor of size {data_size}" | ||
) | ||
if ( | ||
data_size[0] | ||
!= checkpoint["hyper_parameters"]["config"]["preprocessing"]["audio"]["n_mels"] | ||
): | ||
raise ValueError( | ||
f"We expected the first dimension of your Mel spectrogram to correspond with the number of Mel bands declared by your model ({checkpoint['hyper_parameters']['config']['preprocessing']['audio']['n_mels']}). Instead, we found you model has the dimensions {data_size}. If your spectrogram is time-oriented, please re-run this command with the '--time-oriented' flag." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if time_oriented: | |
data = data.transpose(0, 1) | |
data_size = data.size() | |
if ( | |
checkpoint["hyper_parameters"]["config"]["preprocessing"]["audio"]["n_mels"] | |
not in data_size | |
): | |
raise ValueError( | |
f"Your model expects a spectrogram of dimensions [K (Mel bands), T (frames)] where K == {checkpoint['hyper_parameters']['config']['preprocessing']['audio']['n_mels']} but you provided a tensor of size {data_size}" | |
) | |
if ( | |
data_size[0] | |
!= checkpoint["hyper_parameters"]["config"]["preprocessing"]["audio"]["n_mels"] | |
): | |
raise ValueError( | |
f"We expected the first dimension of your Mel spectrogram to correspond with the number of Mel bands declared by your model ({checkpoint['hyper_parameters']['config']['preprocessing']['audio']['n_mels']}). Instead, we found you model has the dimensions {data_size}. If your spectrogram is time-oriented, please re-run this command with the '--time-oriented' flag." | |
) | |
if time_oriented: | |
data = data.transpose(0, 1) | |
data_size = data.size() | |
config_n_mels = checkpoint["hyper_parameters"]["config"]["preprocessing"]["audio"]["n_mels"] | |
if (config_n_mels not in data_size): | |
raise ValueError( | |
f"Your model expects a spectrogram of dimensions [K (Mel bands), T (frames)] where K == {config_n_mels} but you provided a tensor of size {data_size}" | |
) | |
if (data_size[0] != config_n_mels): | |
raise ValueError( | |
f"We expected the first dimension of your Mel spectrogram to correspond with the number of Mel bands declared by your model ({config_n_mels}). Instead, we found you model has the dimensions {data_size}. If your spectrogram is time-oriented, please re-run this command with the '--time-oriented' flag." | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please accept this suggestion, the code is quite hard to read.
…f time-oriented ones
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please accept Sam's change request, otherwise this looks fine.
if time_oriented: | ||
data = data.transpose(0, 1) | ||
data_size = data.size() | ||
if ( | ||
checkpoint["hyper_parameters"]["config"]["preprocessing"]["audio"]["n_mels"] | ||
not in data_size | ||
): | ||
raise ValueError( | ||
f"Your model expects a spectrogram of dimensions [K (Mel bands), T (frames)] where K == {checkpoint['hyper_parameters']['config']['preprocessing']['audio']['n_mels']} but you provided a tensor of size {data_size}" | ||
) | ||
if ( | ||
data_size[0] | ||
!= checkpoint["hyper_parameters"]["config"]["preprocessing"]["audio"]["n_mels"] | ||
): | ||
raise ValueError( | ||
f"We expected the first dimension of your Mel spectrogram to correspond with the number of Mel bands declared by your model ({checkpoint['hyper_parameters']['config']['preprocessing']['audio']['n_mels']}). Instead, we found you model has the dimensions {data_size}. If your spectrogram is time-oriented, please re-run this command with the '--time-oriented' flag." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please accept this suggestion, the code is quite hard to read.
!= checkpoint["hyper_parameters"]["config"]["preprocessing"]["audio"]["n_mels"] | ||
): | ||
raise ValueError( | ||
f"We expected the first dimension of your Mel spectrogram to correspond with the number of Mel bands declared by your model ({checkpoint['hyper_parameters']['config']['preprocessing']['audio']['n_mels']}). Instead, we found you model has the dimensions {data_size}. If your spectrogram is time-oriented, please re-run this command with the '--time-oriented' flag." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This warning message is good, probably giving the user the feedback I was asking for in the top-level PR.
Note: you'll need to rebase, and solve the merge conflict: we now have to use |
See EveryVoiceTTS/EveryVoice#572