gitycc / g2pw Goto Github PK
View Code? Open in Web Editor NEWChinese Mandarin Grapheme-to-Phoneme Converter. 中文轉注音或拼音 (INTERSPEECH 2022)
Home Page: https://arxiv.org/abs/2203.10430
License: Apache License 2.0
Chinese Mandarin Grapheme-to-Phoneme Converter. 中文轉注音或拼音 (INTERSPEECH 2022)
Home Page: https://arxiv.org/abs/2203.10430
License: Apache License 2.0
調用 GPU 推理功能
測試以下作法能夠成功調用GPU推理
使用 onnxruntime gpu版本
pip install onnxruntime-gpu
測試是否安裝成功
import onnxruntime
print(onnxruntime.get_device())
GPU
測試是否調用成功
ort_session = onnxruntime.InferenceSession("./G2PWModel-v2-onnx/g2pw.onnx",providers=['CUDAExecutionProvider'])
print(ort_session.get_providers())
['CUDAExecutionProvider', 'CPUExecutionProvider']
理論上只須修改此行
Line 70 in 36b02d4
self.session_g2pw = onnxruntime.InferenceSession(os.path.join(model_dir, 'g2pw.onnx'), sess_options=sess_options,providers=['CUDAExecutionProvider'])
I'm testing the onnx version by @BarryKCL and found that once the input len more than 16
, the onnxruntime sess will not give output without any error。。I don't known if it's bug of onnxruntime or feature of g2pw model?
想请教下,您是使用tag_pos.py获得结果后又进行精标了吗?我用train.sent运行tag_pos.py后(里面好多UNK,和预测错误的pos),并不能获得与下载的train.pos一样的结果.
感谢您的工作!
我最近想要重新训练一下g2pW模型,但是我在看issue和cpp_dataset中的数据时有一个问题,在issue中好像讨论的都是当下的模型是基于繁体中文来训练的;而cpp_dataset中的数据却都是简体中文;那么整体训练过程到底是使用了简体还是繁体呢?
期待您的回复。
cool job!
i want to cover 汉字 or pinyin to phoneme, like this:
'你好' ==> 'n i h ao' or
'ni3 hao3' ==>'n i h ao '
could you give some instruction?
您提供的checkpoints,大小是600M;
用您的代码跑出来的模型大小同400M。
请问这差的200M,是啥原因导致的呀?
Thanks for the excellent work, @BarryKCL has included g2pW into PaddleSpeech , which greatly improves the accuracy of polyphone.
PaddleSpeech is an open-source toolkit on PaddlePaddle platform for a variety of critical tasks in speech and audio, with the state-of-art and influential models.
@BarryKCL converted the torch model to onnx
and replace dependence transformers
with paddlenlp
.
Thank you again from the bottom of my heart !😘
check:
hi,
Thanks the provided code and model.
When i use the g2pw to do g2p, it cost too long time.
conv = G2PWConverter(style='pinyin', enable_non_tradional_chinese=True)
I inference 60 characters, cost 0.86s on cpu, have any way to accelerate it? Thanks again.
conv = G2PWConverter(style='pinyin', enable_non_tradional_chinese=True)
conv('我和你')
[['wo3', 'han4', 'ni3']]
如上图, 测试发现“和”字拼音转成了han4
您好,实际使用中,大部分多音字预测效果还可以,对于多音字"厦"预测,这个特别容易出错,这几个句子都会读成xia4
通过西门来访者可以进入大厦。
沈阳皇朝万鑫国际大厦
请问这块是因为实际训练集的影响,还是其它原因呢?看论文实际训练多音字是432个,方便问下具体是哪些多音字吗?
头发
拥抱
.. maybe there are many cases..
Although this tool can handle polyphony words well, it is wrong for some common Mandarin pronunciation, maybe for mandarin users, we can use pypinyin to get partial_results
in prepare_data ?
we can first replace the non polyphone chars:
but "拥" is polyphone, I need to find another way to solve it
擁 ㄩㄥ3
擁 ㄩㄥ1
maybe we have to modify POLYPHONIC_CHARS.txt
refer to this https://www.zhihu.com/question/31151037
predict.sh:
python scripts/predict_g2p_bert.py
--config saved_models/CPP_BERT_M_DescWS-Sec-cLin-B_POSw01/config.py
--checkpoint saved_models/CPP_BERT_M_DescWS-Sec-cLin-B_POSw01/best_accuracy.pth
--sent_path cpp_dataset/test2.sent
--output_path output_pred.txt
(chatchat) root@a100:/home/data/tts/wetts/shtel/g2pW# sh predict.sh
Some weights of G2PW were not initialized from the model checkpoint at /home/nas/modelhub/llm/bert-base-chinese and are newly initialized: ['char_descriptor.weight', 'classifier.bias', 'pos_classifier.bias', 'second_order_descriptor.weight', 'classifier.weight', 'pos_classifier.weight', 'descriptor_bias.weight']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.
Traceback (most recent call last):
File "/home/data/tts/wetts/shtel/g2pW/scripts/predict_g2p_bert.py", line 86, in
main(config, opt.checkpoint, opt.sent_path, output_path=opt.output_path)
File "/home/data/tts/wetts/shtel/g2pW/scripts/predict_g2p_bert.py", line 58, in main
preds, confidences = predict(model, dataloader, device, labels)
File "/home/data/tts/wetts/shtel/g2pW/./g2pw/api.py", line 29, in predict
probs = onnx_session.run(
File "/opt/conda/envs/chatchat/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1695, in getattr
raise AttributeError(f"'{type(self).name}' object has no attribute '{name}'")
AttributeError: 'G2PW' object has no attribute 'run'
看起来predict函数的第一个参数应该是一个onnx-session,但是predict_g2p_bert.py里传入predict第一个参数的是model = G2PW.from_pretrained
miniforge3/lib/python3.9/multiprocessing/spawn.py", line 134, in _check_not_importing_main
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
simple code:
from g2pw import G2PWConverter
conv = G2PWConverter(style='pinyin', enable_non_tradional_chinese=True)
conv('然而,他红了20年以后,他竟退出了大家的视线。')
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.