31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
|
|
#
|
|
# 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.
|
|
'''
|
|
Defines the set of symbols used in text input to the model.
|
|
|
|
The default is a set of ASCII characters that works well for English or text that has been run
|
|
through Unidecode. For other data, you can modify _characters. See TRAINING_DATA.md for details.
|
|
'''
|
|
from .cmudict import valid_symbols
|
|
|
|
_pad = '_'
|
|
_eos = '~'
|
|
_characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!\'(),-.:;? '
|
|
|
|
# Prepend "@" to ARPAbet symbols to ensure uniqueness (some are the same as uppercase letters):
|
|
_arpabet = ['@' + s for s in valid_symbols]
|
|
|
|
# Export all symbols:
|
|
symbols = [_pad, _eos] + list(_characters) + _arpabet
|