mirror of
https://github.com/k2-fsa/icefall.git
synced 2025-09-09 17:14:20 +00:00
add necessary utility files
This commit is contained in:
parent
189d424b25
commit
0e7df7c5c4
37
egs/libriheavy/ASR/local/bpe2tokens.py
Executable file
37
egs/libriheavy/ASR/local/bpe2tokens.py
Executable file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
This script takes `bpe.model` as input and generates a file `tokens.txt`
|
||||
from it.
|
||||
|
||||
Usage:
|
||||
./bpe_model_to_tokens.py /path/to/input/bpe.model > tokens.txt
|
||||
"""
|
||||
import argparse
|
||||
|
||||
import sentencepiece as spm
|
||||
|
||||
|
||||
def get_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"bpe_model",
|
||||
type=str,
|
||||
help="Path to the input bpe.model",
|
||||
)
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main():
|
||||
args = get_args()
|
||||
|
||||
sp = spm.SentencePieceProcessor()
|
||||
sp.load(args.bpe_model)
|
||||
|
||||
for i in range(sp.vocab_size()):
|
||||
print(sp.id_to_piece(i), i)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
1
egs/libriheavy/ASR/local/prepare_lang.py
Symbolic link
1
egs/libriheavy/ASR/local/prepare_lang.py
Symbolic link
@ -0,0 +1 @@
|
||||
../../../librispeech/ASR/local/prepare_lang.py
|
Loading…
x
Reference in New Issue
Block a user