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

Improving repeatability of voice cloning #384

Closed
ghost opened this issue Jun 27, 2020 · 3 comments
Closed

Improving repeatability of voice cloning #384

ghost opened this issue Jun 27, 2020 · 3 comments

Comments

@ghost
Copy link

ghost commented Jun 27, 2020

How can I make the voice cloning results repeatable? For a given model with same input.wav + text to synthesize, is there a way to ensure that I get the same output every time?

I see this code in synthesizer/train.py:

# Start by setting a seed for repeatability
tf.compat.v1.set_random_seed(hparams.tacotron_random_seed)

I tried inserting this in demo_cli.py and still get different results each time. Even if the program is restarted in between cloning attempts.

@ghost
Copy link
Author

ghost commented Jul 8, 2020

After reviewing code from @plummet555 , I realize that we should also set random.seed() for the python built-in RNG and np.random.seed() for the numpy RNG. I will try this later and see if repeatability improves.

@ghost
Copy link
Author

ghost commented Jul 19, 2020

With the changes on the 384_repeatable_voice_cloning branch of my fork, I get fully repeatable voice cloning output using demo_toolbox.py . Tested on a computer without a GPU.

Test case

You should find that the exported .wav files are identical for subsequent synthesize and vocode attempts within a session, and even across new toolbox sessions.

Required changes

  1. Reload synthesizer and vocoder models every time they are used
  2. Set torch.manual_seed() every time the vocoder is used
  3. Set tensorflow seed every time synthesizer is used

Other changes

I reverted these changes and results are still repeatable on my platform. Listing here in case it helps troubleshooting in the future.

  1. Force tensorflow to use a single-threaded session
  2. Use kernel initializer for tf.nn.rnn_cell.GRUCell() and tf.layers.dense()
    • This might affect repeatability of training, but without these, inference is still repeatable.

References

(2) https://pytorch.org/docs/stable/notes/randomness.html
(3, 4) https://stackoverflow.com/a/52897216
(5) https://stackoverflow.com/a/51558159

@ghost
Copy link
Author

ghost commented Jul 22, 2020

Closing now that #432 is merged.

@ghost ghost closed this as completed Jul 22, 2020
This issue was closed.
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

0 participants