Answers.Body: <p>There are two &quot;inputs&quot; into Wavenet:</p>
  <ul>
  <li>the previously generated samples of the waveform, which are usually encoded into multiple channels, like into 256 channels using 8-bit <a href="https://en.wikipedia.org/wiki/%CE%9C-law_algorithm" rel="nofollow noreferrer">mu-law encoding</a></li>
  <li>local conditioning, which can be things like linguistic features such as phoneme classes (used in the original wavenet paper), or frequencies like mel spectrogram values (used in the <a href="https://arxiv.org/pdf/1712.05884.pdf" rel="nofollow noreferrer">Tacotron 2 paper</a>)</li>
  </ul>
  <p>The local conditioning signal usually has a much lower resolution than the waveform itself. For example, the Tacotron 2 paper mentioned using &quot;50 ms frame size, 12.5 ms frame hop&quot; to derive its mel spectogram values. At 24 kHz, each waveform sample has a duration of just 0.0416 ms. So in order to using the spectogram information to condition the waveform generation, it would have to be upsampled to spread out along the time dimension. (If you were locally conditioning using letters, you might turn &quot;dog&quot; into &quot;dddddoooooooooggg&quot; in order to use the letter &quot;d&quot; to generate 5 samples in the output waveform, etc.).</p>
  <blockquote>
  <ol>
  <li>What is the input to the WaveNet, isn't this a mel-spectrum input and not just 1 floating point value for raw audio?</li>
  </ol>
  </blockquote>
  <p>In the implementation you linked to, it looks like variables that start with &quot;c&quot; refer to &quot;conditioning&quot; signals. So &quot;hparams.cin_channels&quot; indicates how many channels the input conditioning signal has. If that signal is mel spectogram with 80 channels, then it would be set to 80.</p>
  <p>It looks like the &quot;inference/input_convolution&quot; layer is processing the actual waveform, not the spectogram conditioning signal.</p>
  <blockquote>
  <ol start="2">
  <li>Is there reason for upsampling stride values to be [11, 25], like are the specific numbers 11 and 25 special or relevant in affecting other shapes/dimensions?</li>
  </ol>
  </blockquote>
  <p>I suspect (though I'm not too familiar with tensorflow conventions) that the second dimension is time, which is why you're seeing the model upsample the conditioning signal in that direction. Those values may be required to match the resolution of the waveform being generated.</p>
  <blockquote>
  <ol start="3">
  <li>Why is the input-channels in residual_block_causal_conv 128 and residual_block_cin_conv 80? What exactly is their inputs?</li>
  </ol>
  </blockquote>
  <p>The &quot;c&quot; in &quot;cin_conv&quot; appears to mean that it is for the conditioning signal, which is why is has a different dimension than the waveform's embedding size.</p>
  <p>I hope this helps. You could also try opening up an issue on that github repo to try getting help directly from the author.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-31T01:34:30.230Z
Answers.LastActivityDate: 2020-10-31T01:34:30.230Z
Answers.UserDisplayName: Robz
Body: <p>I am currently studying this model speech generation known as <a href="https://arxiv.org/pdf/1609.03499.pdf" rel="nofollow noreferrer">WaveNet model by Google</a> using the linked original paper and <a href="https://github.com/Rayhane-mamah/Tacotron-2/blob/master/wavenet_vocoder/models/wavenet.py" rel="nofollow noreferrer">this implementation</a>.</p>
  <p>I find the model very confusing in the input it takes and the output it generates, and some of the layer dimensions didn't seem to match based on what I understood from the WaveNet paper, or am I misunderstanding something?</p>
  <ol>
  <li>What is the input to the WaveNet, isn't this a mel-spectrum input and not just 1  floating point value for raw audio? E.g. the input kernel layer shows as shaped 1x1x128. Isn't the input to the <code>input_convolution</code> layer the mel-spectrum frames, which are 80 float values * 10,000 max_decoder_steps, so the in_channels for this conv1d layer should be 80 instead of 1?</li>
  </ol>
  <blockquote>
  <p>inference/input_convolution/kernel:0 (float32_ref 1x1x128) [128, bytes: 512]</p>
  </blockquote>
  <ol start="2">
  <li>Is there reason for upsampling stride values to be [11, 25], like are the specific numbers 11 and 25 special or relevant in affecting other shapes/dimensions?</li>
  </ol>
  <pre><code>inference/ConvTranspose1D_layer_0/kernel:0 (float32_ref 1x11x80x80) [70400, bytes: 281600]
  inference/ConvTranspose1D_layer_1/kernel:0 (float32_ref 1x25x80x80) [160000, bytes: 640000]
  </code></pre>
  <ol start="3">
  <li>Why is the input-channels in  residual_block_causal_conv 128 and residual_block_cin_conv 80? What exactly is their inputs? (e.g. is it mel-spectrum or just a raw floating point value?) Is the wavenet-vocoder generating just 1 float value per 1 input mel-spectrum frame of 80 floats?</li>
  </ol>
  <pre><code>inference/ResidualConv1DGLU_0/residual_block_causal_conv_ResidualConv1DGLU_0/kernel:0 (float32_ref 3x128x256) [98304, bytes: 393216]
  inference/ResidualConv1DGLU_0/residual_block_cin_conv_ResidualConv1DGLU_0/kernel:0 (float32_ref 1x80x256) [20480, bytes: 81920]
  </code></pre>
  <p>I was able to print the whole WaveNet network using <code>print(tf.trainable_variables())</code>, but the model still seems very confusing.</p>
  
Tags: <deep-learning><tensorflow><speech-recognition><speech-synthesis><transpose-convolution>
Title: Studying the speech-generation model and have question about the confusing nature of model input and outputs
UserDisplayName: Joe Black
ThreadText: # Studying the speech-generation model and have question about the confusing nature of model input and outputs
  
  (Asked by: username_0 on 2020-06-12)
  
  I am currently studying this model speech generation known as WaveNet model by Google using the linked original paper and this implementation.
  I find the model very confusing in the input it takes and the output it generates, and some of the layer dimensions didn't seem to match based on what I understood from the WaveNet paper, or am I misunderstanding something?
  
  What is the input to the WaveNet, isn't this a mel-spectrum input and not just 1  floating point value for raw audio? E.g. the input kernel layer shows as shaped 1x1x128. Isn't the input to the input_convolution layer the mel-spectrum frames, which are 80 float values * 10,000 max_decoder_steps, so the in_channels for this conv1d layer should be 80 instead of 1?
  
  
  inference/input_convolution/kernel:0 (float32_ref 1x1x128) [128, bytes: 512]
  
  
  Is there reason for upsampling stride values to be [11, 25], like are the specific numbers 11 and 25 special or relevant in affecting other shapes/dimensions?
  
  inference/ConvTranspose1D_layer_0/kernel:0 (float32_ref 1x11x80x80) [70400, bytes: 281600]
  inference/ConvTranspose1D_layer_1/kernel:0 (float32_ref 1x25x80x80) [160000, bytes: 640000]
  
  
  Why is the input-channels in  residual_block_causal_conv 128 and residual_block_cin_conv 80? What exactly is their inputs? (e.g. is it mel-spectrum or just a raw floating point value?) Is the wavenet-vocoder generating just 1 float value per 1 input mel-spectrum frame of 80 floats?
  
  inference/ResidualConv1DGLU_0/residual_block_causal_conv_ResidualConv1DGLU_0/kernel:0 (float32_ref 3x128x256) [98304, bytes: 393216]
  inference/ResidualConv1DGLU_0/residual_block_cin_conv_ResidualConv1DGLU_0/kernel:0 (float32_ref 1x80x256) [20480, bytes: 81920]
  
  I was able to print the whole WaveNet network using print(tf.trainable_variables()), but the model still seems very confusing.
  
  **Tags:** deep-learning, tensorflow, speech-recognition, speech-synthesis, transpose-convolution
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-10-31. Score: 1
  
  There are two "inputs" into Wavenet:
  
  * the previously generated samples of the waveform, which are usually encoded into multiple channels, like into 256 channels using 8-bit [mu-law encoding](https://en.wikipedia.org/wiki/%CE%9C-law_algorithm)
  * local conditioning, which can be things like linguistic features such as phoneme classes (used in the original wavenet paper), or frequencies like mel spectrogram values (used in the [Tacotron 2 paper](https://arxiv.org/pdf/1712.05884.pdf))
  
  The local conditioning signal usually has a much lower resolution than the waveform itself. For example, the Tacotron 2 paper mentioned using "50 ms frame size, 12.5 ms frame hop" to derive its mel spectogram values. At 24 kHz, each waveform sample has a duration of just 0.0416 ms. So in order to using the spectogram information to condition the waveform generation, it would have to be upsampled to spread out along the time dimension. (If you were locally conditioning using letters, you might turn "dog" into "dddddoooooooooggg" in order to use the letter "d" to generate 5 samples in the output waveform, etc.).
  
  > 1. What is the input to the WaveNet, isn't this a mel-spectrum input and not just 1 floating point value for raw audio?
  
  In the implementation you linked to, it looks like variables that start with "c" refer to "conditioning" signals. So "hparams.cin\_channels" indicates how many channels the input conditioning signal has. If that signal is mel spectogram with 80 channels, then it would be set to 80.
  
  It looks like the "inference/input\_convolution" layer is processing the actual waveform, not the spectogram conditioning signal.
  
  > 2. Is there reason for upsampling stride values to be [11, 25], like are the specific numbers 11 and 25 special or relevant in affecting other shapes/dimensions?
  
  I suspect (though I'm not too familiar with tensorflow conventions) that the second dimension is time, which is why you're seeing the model upsample the conditioning signal in that direction. Those values may be required to match the resolution of the waveform being generated.
  
  > 3. Why is the input-channels in residual\_block\_causal\_conv 128 and residual\_block\_cin\_conv 80? What exactly is their inputs?
  
  The "c" in "cin\_conv" appears to mean that it is for the conditioning signal, which is why is has a different dimension than the waveform's embedding size.
  
  I hope this helps. You could also try opening up an issue on that github repo to try getting help directly from the author.
  
  
  ---
  
  