(peak=10.0, hz_flat=1000, sr=16000, n_fft=512)
return tf.constant(mask[np.newaxis, :, np.newaxis], dtype=tf.float32)
Calculates a mask to weight lower frequencies higher.

  Piecewise linear approximation. Assumes magnitude is in log scale.
  Args:
    peak: Cost increase at 0 Hz.
    hz_flat: Hz at which cost increase is 0.
    sr: Sample rate.
    n_fft: FFT size.

  Returns:
    Constant tensor [1, N_freq, 1] of cost weighting.
Calculates a mask to weight lower frequencies higher.
Calculates a mask to weight lower frequencies higher .
def frequency_weighted_cost_mask(peak=10.0, hz_flat=1000, sr=16000, n_fft=512):
  """Calculates a mask to weight lower frequencies higher.

  Piecewise linear approximation. Assumes magnitude is in log scale.
  Args:
    peak: Cost increase at 0 Hz.
    hz_flat: Hz at which cost increase is 0.
    sr: Sample rate.
    n_fft: FFT size.

  Returns:
    Constant tensor [1, N_freq, 1] of cost weighting.
  """
  n = int(n_fft / 2)
  cutoff = np.where(
      librosa.core.fft_frequencies(sr=sr, n_fft=n_fft) >= hz_flat)[0][0]
  mask = np.concatenate([np.linspace(peak, 1.0, cutoff), np.ones(n - cutoff)])
  return tf.constant(mask[np.newaxis, :, np.newaxis], dtype=tf.float32)
def frequency_weighted_cost_mask ( peak = 10.0 , hz_flat = 1000 , sr = 16000 , n_fft = 512 ) : n = int ( n_fft / 2 ) cutoff = np . where ( librosa . core . fft_frequencies ( sr = sr , n_fft = n_fft ) >= hz_flat ) [ 0 ] [ 0 ] mask = np . concatenate ( [ np . linspace ( peak , 1.0 , cutoff ) , np . ones ( n - cutoff ) ] ) return tf . constant ( mask [ np . newaxis , : , np . newaxis ] , dtype = tf . float32 )