flexthink commited on
Commit
0ad8d41
1 Parent(s): 73b13d4

SoundChoice G2P: Initial model import

Browse files
Files changed (6) hide show
  1. .gitattributes +2 -0
  2. LICENSE +201 -0
  3. README.md +100 -0
  4. ctc_lin.ckpt +3 -0
  5. hyperparams.yaml +507 -0
  6. model.ckpt +3 -0
.gitattributes CHANGED
@@ -29,3 +29,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
29
  *.zip filter=lfs diff=lfs merge=lfs -text
30
  *.zstandard filter=lfs diff=lfs merge=lfs -text
31
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
29
  *.zip filter=lfs diff=lfs merge=lfs -text
30
  *.zstandard filter=lfs diff=lfs merge=lfs -text
31
  *tfevents* filter=lfs diff=lfs merge=lfs -text
32
+ ctc_lin.ckpt filter=lfs diff=lfs merge=lfs -text
33
+ model.ckpt filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
README.md CHANGED
@@ -1,3 +1,103 @@
1
  ---
2
  license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  ---
4
+ # SoundChoice: Grapheme-to-Phoneme Models with Semantic Disambiguation
5
+
6
+ This repository provides all the necessary tools to perform English grapheme-to-phoneme conversion with a pretrained SoundChoice G2P model using SpeechBrain. It is trained on LibriG2P training data derived from [LibriSpeech Alignments](https://zenodo.org/record/2619474#.YuCdaC8r1ZF) and [Google Wikipedia](https://github.com/google/WikipediaHomographData)
7
+
8
+
9
+ ## Install SpeechBrain
10
+
11
+ First of all, please install SpeechBrain with the following command:
12
+
13
+ ```bash
14
+ pip install speechbrain
15
+ ```
16
+
17
+ Please notice that we encourage you to read our tutorials and learn more about
18
+ [SpeechBrain](https://speechbrain.github.io).
19
+
20
+ ## Perform G2P Conversion
21
+
22
+ Please follow the example below to perform grapheme-to-phoneme conversion with a high-level wrapper.
23
+
24
+ ```python
25
+ from speechbrain.pretrained import GraphemeToPhoneme
26
+ g2p = GraphemeToPhoneme.from_hparams("speechbrain/soundchoice-g2p")
27
+ text = "To be or not to be, that is the question"
28
+ phonemes = g2p(text)
29
+ ```
30
+
31
+ Given below is the expected output
32
+ ```python
33
+ >>> phonemes
34
+ ['T', 'UW', ' ', 'B', 'IY', ' ', 'AO', 'R', ' ', 'N', 'AA', 'T', ' ', 'T', 'UW', ' ', 'B', 'IY', ' ', 'DH', 'AE', 'T', ' ', 'IH', 'Z', ' ', 'DH', 'AH', ' ', 'K', 'W', 'EH', 'S', 'CH', 'AH', 'N']
35
+ ```
36
+
37
+ To perform G2P conversion on a batch of text, pass
38
+ an array of strings to the interface:
39
+
40
+ ```python
41
+ items = [
42
+ "All's Well That Ends Well",
43
+ "The Merchant of Venice",
44
+ "The Two Gentlemen of Verona",
45
+ "The Comedy of Errors"
46
+ ]
47
+ transcriptions = g2p(items)
48
+ ```
49
+
50
+ Given below is the expected output:
51
+
52
+ ```python
53
+ >>> transcriptions
54
+ [['AO', 'L', 'Z', ' ', 'W', 'EH', 'L', ' ', 'DH', 'AE', 'T', ' ', 'EH', 'N', 'D', 'Z', ' ', 'W', 'EH', 'L'], ['DH', 'AH', ' ', 'M', 'ER', 'CH', 'AH', 'N', 'T', ' ', 'AH', 'V', ' ', 'V', 'EH', 'N', 'AH', 'S'], ['DH', 'AH', ' ', 'T', 'UW', ' ', 'JH', 'EH', 'N', 'T', 'AH', 'L', 'M', 'IH', 'N', ' ', 'AH', 'V', ' ', 'V', 'ER', 'OW', 'N', 'AH'], ['DH', 'AH', ' ', 'K', 'AA', 'M', 'AH', 'D', 'IY', ' ', 'AH', 'V', ' ', 'EH', 'R', 'ER', 'Z']]
55
+ ```
56
+
57
+ ### Inference on GPU
58
+ To perform inference on the GPU, add `run_opts={"device":"cuda"}` when calling the `from_hparams` method.
59
+
60
+ ### Limitations
61
+ The SpeechBrain team does not provide any warranty on the performance achieved by this model when used on other datasets.
62
+
63
+ ### Training
64
+ The model was trained with SpeechBrain (aa018540).
65
+ To train it from scratch follows these steps:
66
+ 1. Clone SpeechBrain:
67
+ ```bash
68
+ git clone https://github.com/speechbrain/speechbrain/
69
+ ```
70
+ 2. Install it:
71
+ ```
72
+ cd speechbrain
73
+ pip install -r requirements.txt
74
+ pip install -e .
75
+ ```
76
+
77
+ 3. Run Training:
78
+ ```
79
+ cd recipes/LibriSpeech/G2P
80
+ python train.py hparams/hparams_g2p_rnn.yaml --data_folder=your_data_folder
81
+ ```
82
+
83
+ Adjust hyperparameters as needed by passing additional arguments.
84
+
85
+ # **Citing SpeechBrain**
86
+ Please, cite SpeechBrain if you use it for your research or business.
87
+
88
+ ```bibtex
89
+ @misc{speechbrain,
90
+ title={{SpeechBrain}: A General-Purpose Speech Toolkit},
91
+ author={Mirco Ravanelli and Titouan Parcollet and Peter Plantinga and Aku Rouhe and Samuele Cornell and Loren Lugosch and Cem Subakan and Nauman Dawalatabad and Abdelwahab Heba and Jianyuan Zhong and Ju-Chieh Chou and Sung-Lin Yeh and Szu-Wei Fu and Chien-Feng Liao and Elena Rastorgueva and François Grondin and William Aris and Hwidong Na and Yan Gao and Renato De Mori and Yoshua Bengio},
92
+ year={2021},
93
+ eprint={2106.04624},
94
+ archivePrefix={arXiv},
95
+ primaryClass={eess.AS},
96
+ note={arXiv:2106.04624}
97
+ }
98
+ ```
99
+
100
+ # **About SpeechBrain**
101
+ - Website: https://speechbrain.github.io/
102
+ - Code: https://github.com/speechbrain/speechbrain/
103
+ - HuggingFace: https://huggingface.co/speechbrain/
ctc_lin.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c72639caba01630cf5ccc9b287b6eb7b79acc2276aa6f5cc23640640ac8f7ee
3
+ size 177319
hyperparams.yaml ADDED
@@ -0,0 +1,507 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated 2022-07-09 from:
2
+ # /notebooks/speechbrain/recipes/LibriSpeech/G2P/hparams/hparams_g2p_rnn.yaml
3
+ # yamllint disable
4
+ # ################################
5
+ # Model: LSTM (encoder) + GRU (decoder) (tokenized)
6
+ # Authors:
7
+ # Loren Lugosch & Mirco Ravanelli 2020
8
+ # Artem Ploujnikov 2021
9
+ # ################################
10
+
11
+ # Seed needs to be set at top of yaml, before objects with parameters are made
12
+ seed: 1234
13
+ __set_seed: !apply:torch.manual_seed [1234]
14
+
15
+
16
+ # Tokenizers
17
+ char_tokenize: false
18
+ char_token_type: unigram # ["unigram", "bpe", "char"]
19
+ char_token_output: 512
20
+ char_token_wordwise: true
21
+ phn_tokenize: false
22
+ phn_token_type: unigram # ["unigram", "bpe", "char"]
23
+ phn_token_output: 512 # index(blank/eos/bos/unk) = 0
24
+ phn_token_wordwise: true
25
+ character_coverage: 1.0
26
+
27
+
28
+ phonemes_count: 43
29
+ graphemes_count: 31
30
+ phonemes_enable_space: true
31
+
32
+ # Training Parameters
33
+ lexicon_epochs: 50
34
+ lexicon_ctc_epochs: 10
35
+ lexicon_limit_to_stop: 50 # No stopping by default, can override
36
+ lexicon_limit_warmup: 50 # No stopping by default, can override
37
+ sentence_epochs: 13
38
+ sentence_ctc_epochs: 10
39
+ sentence_limit_to_stop: 3
40
+ sentence_limit_warmup: 3
41
+ homograph_epochs: 50
42
+ homograph_ctc_epochs: 10
43
+ homograph_limit_to_stop: 5
44
+ homograph_limit_warmup: 10
45
+ lexicon_batch_size: 1024
46
+ sentence_batch_size: 32
47
+ homograph_batch_size: 32
48
+ ctc_weight: 0.5
49
+ homograph_loss_weight: 2.0
50
+ lr: 0.002
51
+ save_for_pretrained: true
52
+
53
+ # Model parameters
54
+ output_neurons: &id004 !apply:speechbrain.utils.hparams.choice
55
+
56
+ value: false
57
+ choices:
58
+ true: 513
59
+ false: 43
60
+
61
+ enc_num_embeddings: &id005 !apply:speechbrain.utils.hparams.choice
62
+ value: false
63
+ choices:
64
+ true: 513
65
+ false: 31
66
+
67
+ enc_dropout: 0.5
68
+ enc_neurons: 512
69
+ enc_num_layers: 4
70
+ dec_dropout: 0.5
71
+ dec_neurons: 512
72
+ dec_att_neurons: 256
73
+ dec_num_layers: 4
74
+ embedding_dim: 512
75
+
76
+ # Determines whether to use BOS (beginning-of-sequence) or EOS (end-of-sequence) tokens
77
+ # Available modes:
78
+ # raw: no BOS/EOS tokens are added
79
+ # bos: a beginning-of-sequence token is added
80
+ # eos: an end-of-sequence token is added
81
+ grapheme_sequence_mode: bos
82
+ phoneme_sequence_mode: bos
83
+
84
+
85
+ # Special Token information
86
+ bos_index: 0
87
+ eos_index: 1
88
+ blank_index: 2
89
+ unk_index: 2
90
+ token_space_index: 512
91
+
92
+
93
+ # Language Model
94
+ lm_emb_dim: 256 # dimension of the embeddings
95
+ lm_rnn_size: 512 # dimension of hidden layers
96
+ lm_layers: 2 # number of hidden layers
97
+ lm_output_neurons: 43
98
+
99
+ # Beam Searcher
100
+ use_language_model: false
101
+ beam_search_min_decode_ratio: 0
102
+ beam_search_max_decode_ratio: 1.0
103
+ beam_search_beam_size: 16
104
+ beam_search_beam_size_valid: 16
105
+ beam_search_eos_threshold: 10.0
106
+ beam_search_using_max_attn_shift: false
107
+ beam_search_max_attn_shift: 10
108
+ beam_search_coverage_penalty: 5.0
109
+ beam_search_lm_weight: 0.5
110
+ beam_search_ctc_weight_decode: 0.4
111
+ beam_search_temperature: 1.25
112
+ beam_search_temperature_lm: 1.0
113
+
114
+ # Word embeddings
115
+ use_word_emb: true
116
+ word_emb_model: bert-base-uncased
117
+ word_emb_dim: 768
118
+ word_emb_enc_dim: 256
119
+ word_emb_norm_type: batch
120
+
121
+ graphemes: &id028
122
+ - A
123
+ - B
124
+ - C
125
+ - D
126
+ - E
127
+ - F
128
+ - G
129
+ - H
130
+ - I
131
+ - J
132
+ - K
133
+ - L
134
+ - M
135
+ - N
136
+ - O
137
+ - P
138
+ - Q
139
+ - R
140
+ - S
141
+ - T
142
+ - U
143
+ - V
144
+ - W
145
+ - X
146
+ - Y
147
+ - Z
148
+ - "'"
149
+ - ' '
150
+
151
+ phonemes: &id001
152
+
153
+
154
+ - AA
155
+ - AE
156
+ - AH
157
+ - AO
158
+ - AW
159
+ - AY
160
+ - B
161
+ - CH
162
+ - D
163
+ - DH
164
+ - EH
165
+ - ER
166
+ - EY
167
+ - F
168
+ - G
169
+ - HH
170
+ - IH
171
+ - IY
172
+ - JH
173
+ - K
174
+ - L
175
+ - M
176
+ - N
177
+ - NG
178
+ - OW
179
+ - OY
180
+ - P
181
+ - R
182
+ - S
183
+ - SH
184
+ - T
185
+ - TH
186
+ - UH
187
+ - UW
188
+ - V
189
+ - W
190
+ - Y
191
+ - Z
192
+ - ZH
193
+ - ' '
194
+
195
+ enc_input_dim: &id003 !apply:speechbrain.lobes.models.g2p.model.input_dim
196
+ use_word_emb: true
197
+ word_emb_enc_dim: 256
198
+ embedding_dim: 512
199
+
200
+
201
+ phn_char_map: &id002 !apply:speechbrain.lobes.models.g2p.dataio.build_token_char_map
202
+
203
+
204
+ # Models
205
+ tokens: *id001
206
+ char_phn_map: &id023 !apply:speechbrain.lobes.models.g2p.dataio.flip_map
207
+ map_dict: *id002
208
+ enc: &id006 !new:speechbrain.nnet.RNN.LSTM
209
+ input_shape: [null, null, *id003]
210
+ bidirectional: true
211
+ hidden_size: 512
212
+ num_layers: 4
213
+ dropout: 0.5
214
+
215
+ lin: &id010 !new:speechbrain.nnet.linear.Linear
216
+ input_size: 512
217
+ n_neurons: *id004
218
+ bias: false
219
+
220
+ ctc_lin: &id013 !new:speechbrain.nnet.linear.Linear
221
+ input_size: 1024
222
+ n_neurons: *id004
223
+ encoder_emb: &id007 !new:speechbrain.nnet.embedding.Embedding
224
+ num_embeddings: *id005
225
+ embedding_dim: 512
226
+
227
+ emb: &id008 !new:speechbrain.nnet.embedding.Embedding
228
+ num_embeddings: *id004
229
+ embedding_dim: 512
230
+
231
+ dec: &id009 !new:speechbrain.nnet.RNN.AttentionalRNNDecoder
232
+ enc_dim: 1024
233
+ input_size: 512
234
+ rnn_type: gru
235
+ attn_type: content
236
+ dropout: 0.5
237
+ hidden_size: 512
238
+ attn_dim: 256
239
+ num_layers: 4
240
+
241
+ word_emb_enc: &id012 !new:speechbrain.lobes.models.g2p.model.WordEmbeddingEncoder
242
+
243
+ word_emb_dim: 768
244
+ word_emb_enc_dim: 256
245
+ norm_type: batch
246
+
247
+ word_emb: !apply:speechbrain.lobes.models.g2p.dataio.lazy_init
248
+ init: !name:speechbrain.wordemb.transformer.TransformerWordEmbeddings
249
+ model: bert-base-uncased
250
+
251
+ log_softmax: &id011 !new:speechbrain.nnet.activations.Softmax
252
+ apply_log: true
253
+
254
+ modules:
255
+ model: &id014 !new:speechbrain.lobes.models.g2p.model.AttentionSeq2Seq
256
+ enc: *id006
257
+ encoder_emb: *id007
258
+ emb: *id008
259
+ dec: *id009
260
+ lin: *id010
261
+ out: *id011
262
+ use_word_emb: true
263
+ word_emb_enc: *id012
264
+ enc: *id006
265
+ encoder_emb: *id007
266
+ emb: *id008
267
+ dec: *id009
268
+ lin: *id010
269
+ ctc_lin: *id013
270
+ out: *id011
271
+ word_emb:
272
+ word_emb_enc: *id012
273
+ model: *id014
274
+ lm_model: &id015 !new:speechbrain.lobes.models.RNNLM.RNNLM
275
+ embedding_dim: 256
276
+ rnn_layers: 2
277
+ rnn_neurons: 512
278
+ output_neurons: 43
279
+ return_hidden: true
280
+
281
+ opt_class: !name:torch.optim.Adam
282
+ lr: 0.002
283
+
284
+ beam_searcher: &id029 !new:speechbrain.decoders.S2SRNNBeamSearcher
285
+ embedding: *id008
286
+ decoder: *id009
287
+ linear: *id010
288
+ ctc_linear: *id013
289
+ bos_index: 0
290
+ eos_index: 1
291
+ blank_index: 2
292
+ min_decode_ratio: 0
293
+ max_decode_ratio: 1.0
294
+ beam_size: 16
295
+ eos_threshold: 10.0
296
+ using_max_attn_shift: false
297
+ max_attn_shift: 10
298
+ coverage_penalty: 5.0
299
+ ctc_weight: 0.4
300
+
301
+ beam_searcher_valid: !new:speechbrain.decoders.S2SRNNBeamSearcher
302
+ embedding: *id008
303
+ decoder: *id009
304
+ linear: *id010
305
+ ctc_linear: *id013
306
+ bos_index: 0
307
+ eos_index: 1
308
+ blank_index: 2
309
+ min_decode_ratio: 0
310
+ max_decode_ratio: 1.0
311
+ beam_size: 16
312
+ eos_threshold: 10.0
313
+ using_max_attn_shift: false
314
+ max_attn_shift: 10
315
+ coverage_penalty: 5.0
316
+ ctc_weight: 0.4
317
+
318
+ beam_searcher_lm: !new:speechbrain.decoders.seq2seq.S2SRNNBeamSearchLM
319
+ embedding: *id008
320
+ decoder: *id009
321
+ linear: *id010
322
+ ctc_linear: *id013
323
+ language_model: *id015
324
+ bos_index: 0
325
+ eos_index: 1
326
+ blank_index: 2
327
+ min_decode_ratio: 0
328
+ max_decode_ratio: 1.0
329
+ beam_size: 16
330
+ eos_threshold: 10.0
331
+ using_max_attn_shift: false
332
+ max_attn_shift: 10
333
+ coverage_penalty: 5.0
334
+ ctc_weight: 0.4
335
+ lm_weight: 0.5
336
+ temperature: 1.25
337
+ temperature_lm: 1.0
338
+
339
+
340
+ lr_annealing: &id018 !new:speechbrain.nnet.schedulers.NewBobScheduler
341
+ initial_value: 0.002
342
+ improvement_threshold: 0.0
343
+ annealing_factor: 0.8
344
+ patient: 0
345
+
346
+ homograph_extractor: !new:speechbrain.lobes.models.g2p.homograph.SubsequenceExtractor
347
+
348
+ seq_cost: &id016 !name:speechbrain.nnet.losses.nll_loss
349
+
350
+ label_smoothing: 0.1
351
+
352
+ ctc_cost: !name:speechbrain.nnet.losses.ctc_loss
353
+ blank_index: 2
354
+
355
+ seq_cost_metric: &id017 !name:speechbrain.nnet.losses.nll_loss
356
+
357
+ label_smoothing: 0.1
358
+ reduction: batch
359
+
360
+ homograph_cost: !new:speechbrain.lobes.models.g2p.homograph.SubsequenceLoss
361
+ seq_cost: *id016
362
+ seq_stats: !name:speechbrain.utils.metric_stats.MetricStats
363
+ metric: *id017
364
+ seq_stats_homograph: !name:speechbrain.utils.metric_stats.MetricStats
365
+ metric: *id017
366
+ classification_stats_homograph: !name:speechbrain.utils.metric_stats.ClassificationStats
367
+
368
+ per_stats: !name:speechbrain.utils.metric_stats.ErrorRateStats
369
+ per_stats_homograph: !name:speechbrain.utils.metric_stats.ErrorRateStats
370
+
371
+
372
+ model_output_keys:
373
+ - p_seq
374
+ - char_lens
375
+ - encoder_out
376
+
377
+ grapheme_encoder: &id027 !new:speechbrain.dataio.encoder.TextEncoder
378
+ phoneme_encoder: &id024 !new:speechbrain.dataio.encoder.TextEncoder
379
+
380
+
381
+ grapheme_tokenizer: !apply:speechbrain.lobes.models.g2p.dataio.lazy_init
382
+ init: !name:speechbrain.tokenizers.SentencePiece.SentencePiece
383
+ model_dir: grapheme_tokenizer
384
+ bos_id: 0
385
+ eos_id: 1
386
+ unk_id: 2
387
+ vocab_size: 512
388
+ annotation_train: tokenizer_annotation_train.json
389
+ annotation_read: char
390
+ model_type: unigram # ["unigram", "bpe", "char"]
391
+ character_coverage: 1.0
392
+ annotation_format: json
393
+ text_file: grapheme_annotations.txt
394
+
395
+ phoneme_tokenizer: &id022 !apply:speechbrain.lobes.models.g2p.dataio.lazy_init
396
+ init: !name:speechbrain.tokenizers.SentencePiece.SentencePiece
397
+ model_dir: phoneme_tokenizer
398
+ bos_id: 0
399
+ eos_id: 1
400
+ unk_id: 2
401
+ vocab_size: 512
402
+ annotation_train: tokenizer_annotation_train.json
403
+ annotation_read: phn
404
+ model_type: unigram # ["unigram", "bpe", "char"]
405
+ character_coverage: 1.0
406
+ annotation_list_to_check: [tokenizer_annotation_valid.json]
407
+ annotation_format: json
408
+ text_file: phoneme_annotations.txt
409
+
410
+ out_phoneme_decoder_tok: &id025 !apply:speechbrain.lobes.models.g2p.dataio.char_map_detokenize
411
+ tokenizer: *id022
412
+ char_map: *id023
413
+ token_space_index: 512
414
+ wordwise: true
415
+
416
+ out_phoneme_decoder_raw: &id026 !name:speechbrain.lobes.models.g2p.dataio.text_decode
417
+
418
+ encoder: *id024
419
+ out_phoneme_decoder: !apply:speechbrain.utils.hparams.choice
420
+ value: false
421
+ choices:
422
+ true: *id025
423
+ false: *id026
424
+ encode_pipeline:
425
+ batch: false
426
+ use_padded_data: true
427
+ output_keys:
428
+ - grapheme_list
429
+ - grapheme_encoded_list
430
+ - grapheme_encoded
431
+ - word_emb
432
+ init:
433
+ - func: !name:speechbrain.lobes.models.g2p.dataio.enable_eos_bos
434
+ encoder: *id027
435
+ tokens: *id028
436
+ bos_index: 0
437
+ eos_index: 1
438
+ - func: !name:speechbrain.lobes.models.g2p.dataio.enable_eos_bos
439
+ encoder: *id024
440
+ tokens: *id001
441
+ bos_index: 0
442
+ eos_index: 1
443
+ steps:
444
+ - func: !name:speechbrain.lobes.models.g2p.dataio.clean_pipeline
445
+ graphemes: *id028
446
+ takes: txt
447
+ provides: txt_cleaned
448
+ - func: !name:speechbrain.lobes.models.g2p.dataio.grapheme_pipeline
449
+ grapheme_encoder: *id027
450
+ takes: txt_cleaned
451
+ provides:
452
+ - grapheme_list
453
+ - grapheme_encoded_list
454
+ - grapheme_encoded_raw
455
+
456
+ - func: !name:speechbrain.lobes.models.g2p.dataio.add_bos_eos
457
+ encoder: *id027
458
+ takes: grapheme_encoded_list
459
+ provides:
460
+ - grapheme_encoded
461
+ - grapheme_len
462
+ - grapheme_encoded_eos
463
+ - grapheme_len_eos
464
+ - func: !name:speechbrain.lobes.models.g2p.dataio.word_emb_pipeline
465
+ word_emb: !ref <word_emb>
466
+ grapheme_encoder: !ref <grapheme_encoder>
467
+ use_word_emb: !ref <use_word_emb>
468
+ takes:
469
+ - txt
470
+ - grapheme_encoded
471
+ - grapheme_len
472
+ provides: word_emb
473
+
474
+ decode_pipeline:
475
+ batch: true
476
+ output_keys:
477
+ - phonemes
478
+ steps:
479
+ - func: !name:speechbrain.lobes.models.g2p.dataio.beam_search_pipeline
480
+ beam_searcher: *id029
481
+ takes:
482
+ - char_lens
483
+ - encoder_out
484
+ provides:
485
+ - hyps
486
+ - scores
487
+ - func: !apply:speechbrain.utils.hparams.choice
488
+ value: false
489
+ choices:
490
+ true: !apply:speechbrain.lobes.models.g2p.dataio.char_map_detokenize
491
+ tokenizer: *id022
492
+ char_map: *id023
493
+ token_space_index: 512
494
+ wordwise: true
495
+ false: !name:speechbrain.lobes.models.g2p.dataio.phoneme_decoder_pipeline
496
+ phoneme_encoder: *id024
497
+ takes:
498
+ - hyps
499
+ provides:
500
+ - phonemes
501
+
502
+
503
+ pretrainer: !new:speechbrain.utils.parameter_transfer.Pretrainer
504
+ loadables:
505
+ model: *id014
506
+ ctc_lin: *id013
507
+
model.ckpt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:71bf7a7b290f88de5fdd7364fa4ab249bdd94a29e6cdc742ee6f69edeae64f61
3
+ size 128643257