Merge pull request #2802 from lissyx/sample_rate_checking

Ensure sample rate comparison with proper types
This commit is contained in:
lissyx 2020-02-28 11:56:27 +01:00 committed by GitHub
commit fe8ee4f778
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -31,8 +31,13 @@ def read_csvs(csv_files):
def samples_to_mfccs(samples, sample_rate, train_phase=False, wav_filename=None):
if train_phase and sample_rate != FLAGS.audio_sample_rate:
tf.print('WARNING: sample rate of file', wav_filename, '(', sample_rate, ') does not match FLAGS.audio_sample_rate. This can lead to incorrect results.')
if train_phase:
# We need the lambdas to make TensorFlow happy.
# pylint: disable=unnecessary-lambda
tf.cond(tf.math.not_equal(sample_rate, FLAGS.audio_sample_rate),
lambda: tf.print('WARNING: sample rate of file', wav_filename, '(', sample_rate, ') does not match FLAGS.audio_sample_rate. This can lead to incorrect results.'),
lambda: tf.no_op(),
name='matching_sample_rate')
spectrogram = contrib_audio.audio_spectrogram(samples,
window_size=Config.audio_window_samples,