Skip to content

Commit 4414d81

Browse files
committed
✍️ update training script
1 parent 50d246c commit 4414d81

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

examples/conformer/train_tpu_keras_subword_conformer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
global_batch_size *= strategy.num_replicas_in_sync
9898
# build model
9999
conformer = Conformer(**config.model_config, vocabulary_size=text_featurizer.num_classes)
100-
conformer._build(speech_featurizer.shape, prediction_shape=text_featurizer.prepand_shape, batch_size=batch_size)
100+
conformer._build(speech_featurizer.shape, prediction_shape=text_featurizer.prepand_shape, batch_size=global_batch_size)
101101
conformer.summary(line_length=120)
102102

103103
optimizer = tf.keras.optimizers.Adam(

tensorflow_asr/featurizers/speech_featurizers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
tpu = has_tpu()
2828

2929

30+
# def tf_resample(signal, rate_in, rate_out):
31+
# if rate_in == rate_out: return signal
32+
# rate_in = tf.cast(rate_in, dtype=tf.float32)
33+
# rate_out = tf.cast(rate_out, dtype=tf.float32)
34+
# ratio = rate_out / rate_in
35+
# nsamples = tf.math.ceil(tf.shape(signal)[0] * ratio)
36+
37+
3038
def load_and_convert_to_wav(path: str) -> tf.Tensor:
3139
wave, rate = librosa.load(os.path.expanduser(path), sr=None, mono=True)
3240
return tf.audio.encode_wav(tf.expand_dims(wave, axis=-1), sample_rate=rate)

0 commit comments

Comments
 (0)