From fa473fc25ccc451bcc386cb96722cbfa5a332f08 Mon Sep 17 00:00:00 2001 From: whzikaros Date: Sat, 4 Mar 2023 08:04:10 +0000 Subject: [PATCH] fixed --- README.md | 2 +- g2pL/g2pL.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c96cc05..3956d5c 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ pip install -r requirements.txt ``` ## Download -[点击此处](https://github.com/whzikaros/g2pL/releases/tag/v0.0.1)下载模型及词向量等相关文件,将这些文件放入g2pL目录中。 +[点击此处](https://github.com/whzikaros/g2pL/releases/tag/v0.0.1)下载模型及词向量等相关文件,将这些文件放入g2pL_files目录中。 ## Usage You can set the tone style, the default tone style is 2. diff --git a/g2pL/g2pL.py b/g2pL/g2pL.py index b065de4..3afbaf7 100644 --- a/g2pL/g2pL.py +++ b/g2pL/g2pL.py @@ -23,6 +23,8 @@ dir=os.path.dirname(os.path.abspath(__file__)) +file_dir=os.path.join(os.path.dirname(dir),"g2pL_files") + import collections class TrieNode: @@ -184,7 +186,7 @@ def __init__(self): self.class2idx = pickle.load(f) self.num_classes = len(self.class2idx) - self.embedding_file=os.path.join(dir,"saved_word_embedding_1000000.pkl") + self.embedding_file=os.path.join(file_dir,"saved_word_embedding_1000000.pkl") #self.embedding_file="/media/data2/wanhongzhi/my_polyphone_inference/data/embedding/saved_word_embedding_1000000.pkl" if not os.path.exists(self.embedding_file): download_model(embedding_url,self.embedding_file) @@ -196,7 +198,7 @@ def __init__(self): with open(os.path.join(dir,"matched_word.txt"),'r') as f: matched_words=f.readlines() - self.word_vocab_file=os.path.join(dir,"tencent_vocab.txt") + self.word_vocab_file=os.path.join(file_dir,"tencent_vocab.txt") #self.word_vocab_file="/media/data2/wanhongzhi/my_polyphone_inference/data/vocab/tencent_vocab.txt" if not os.path.exists(self.word_vocab_file): download_model(word_vocab_url,self.word_vocab_file) @@ -207,7 +209,7 @@ def __init__(self): self.word_vocab = ItemVocabArray(items_array=matched_words, is_word=True, has_default=False, unk_num=5) - self.inference_model=os.path.join(dir,"best_model.pt") + self.inference_model=os.path.join(file_dir,"best_model.pt") #self.inference_model="/media/data2/wanhongzhi/my_polyphone_inference/g2pL_files/best_model.pt" if not os.path.exists(self.inference_model): download_model(model_url,self.inference_model)