-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from TensorSpeech/dev/testing
Add unittest and Transducer Joint activation
- Loading branch information
Showing
29 changed files
with
746 additions
and
599 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ | |
|
||
setuptools.setup( | ||
name="TensorFlowASR", | ||
version="0.6.0", | ||
version="0.6.1", | ||
author="Huy Le Nguyen", | ||
author_email="[email protected]", | ||
description="Almost State-of-the-art Automatic Speech Recognition using Tensorflow 2", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Copyright 2020 Huy Le Nguyen (@usimarit) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
speech_config: | ||
sample_rate: 16000 | ||
frame_ms: 25 | ||
stride_ms: 10 | ||
num_feature_bins: 80 | ||
feature_type: log_mel_spectrogram | ||
preemphasis: 0.97 | ||
normalize_signal: True | ||
normalize_feature: True | ||
normalize_per_feature: False | ||
|
||
decoder_config: | ||
vocabulary: null | ||
target_vocab_size: 1024 | ||
max_subword_length: 4 | ||
blank_at_zero: True | ||
beam_width: 5 | ||
norm_score: True | ||
|
||
model_config: | ||
name: conformer | ||
encoder_subsampling: | ||
type: conv2d | ||
filters: 144 | ||
kernel_size: 3 | ||
strides: 2 | ||
encoder_positional_encoding: sinusoid_concat | ||
encoder_dmodel: 144 | ||
encoder_num_blocks: 16 | ||
encoder_head_size: 36 | ||
encoder_num_heads: 4 | ||
encoder_mha_type: relmha | ||
encoder_kernel_size: 32 | ||
encoder_fc_factor: 0.5 | ||
encoder_dropout: 0.1 | ||
prediction_embed_dim: 320 | ||
prediction_embed_dropout: 0 | ||
prediction_num_rnns: 1 | ||
prediction_rnn_units: 320 | ||
prediction_rnn_type: lstm | ||
prediction_rnn_implementation: 1 | ||
prediction_layer_norm: True | ||
prediction_projection_units: 0 | ||
joint_dim: 320 | ||
joint_activation: tanh | ||
|
||
learning_config: | ||
augmentations: | ||
after: | ||
time_masking: | ||
num_masks: 10 | ||
mask_factor: 100 | ||
p_upperbound: 0.05 | ||
freq_masking: | ||
num_masks: 1 | ||
mask_factor: 27 | ||
|
||
dataset_config: | ||
train_paths: | ||
- /mnt/Miscellanea/Datasets/Speech/LibriSpeech/train-clean-100/transcripts.tsv | ||
eval_paths: | ||
- /mnt/Miscellanea/Datasets/Speech/LibriSpeech/dev-clean/transcripts.tsv | ||
- /mnt/Miscellanea/Datasets/Speech/LibriSpeech/dev-other/transcripts.tsv | ||
test_paths: | ||
- /mnt/Miscellanea/Datasets/Speech/LibriSpeech/test-clean/transcripts.tsv | ||
tfrecords_dir: null | ||
|
||
optimizer_config: | ||
warmup_steps: 40000 | ||
beta1: 0.9 | ||
beta2: 0.98 | ||
epsilon: 1e-9 | ||
|
||
running_config: | ||
batch_size: 2 | ||
accumulation_steps: 4 | ||
num_epochs: 20 | ||
outdir: /mnt/Miscellanea/Models/local/conformer | ||
log_interval_steps: 300 | ||
eval_interval_steps: 500 | ||
save_interval_steps: 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright 2020 Huy Le Nguyen (@usimarit) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import os | ||
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3" | ||
import tensorflow as tf | ||
|
||
DEFAULT_YAML = os.path.join(os.path.abspath(os.path.dirname(__file__)), "config.yml") | ||
|
||
from tensorflow_asr.configs.config import Config | ||
from tensorflow_asr.models.conformer import Conformer | ||
from tensorflow_asr.featurizers.text_featurizers import CharFeaturizer | ||
from tensorflow_asr.featurizers.speech_featurizers import TFSpeechFeaturizer | ||
|
||
|
||
def test_conformer(): | ||
config = Config(DEFAULT_YAML, learning=False) | ||
|
||
text_featurizer = CharFeaturizer(config.decoder_config) | ||
|
||
speech_featurizer = TFSpeechFeaturizer(config.speech_config) | ||
|
||
model = Conformer(vocabulary_size=text_featurizer.num_classes, **config.model_config) | ||
|
||
model._build(speech_featurizer.shape) | ||
model.summary(line_length=150) | ||
|
||
model.add_featurizers(speech_featurizer=speech_featurizer, text_featurizer=text_featurizer) | ||
|
||
concrete_func = model.make_tflite_function(timestamp=False).get_concrete_function() | ||
converter = tf.lite.TFLiteConverter.from_concrete_functions([concrete_func]) | ||
converter.optimizations = [tf.lite.Optimize.DEFAULT] | ||
converter.experimental_new_converter = True | ||
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, tf.lite.OpsSet.SELECT_TF_OPS] | ||
converter.convert() | ||
|
||
print("Converted successfully with no timestamp") | ||
|
||
concrete_func = model.make_tflite_function(timestamp=True).get_concrete_function() | ||
converter = tf.lite.TFLiteConverter.from_concrete_functions([concrete_func]) | ||
converter.optimizations = [tf.lite.Optimize.DEFAULT] | ||
converter.experimental_new_converter = True | ||
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, tf.lite.OpsSet.SELECT_TF_OPS] | ||
converter.convert() | ||
|
||
print("Converted successfully with timestamp") |
Oops, something went wrong.