Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
whzikaros committed Mar 4, 2023
1 parent ff1ff35 commit fa473fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 5 additions & 3 deletions g2pL/g2pL.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit fa473fc

Please sign in to comment.