Giter Club home page Giter Club logo

g2pw's People

Contributors

barrykcl avatar gitycc avatar mozillazg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

g2pw's Issues

多音字测试

您好,实际使用中,大部分多音字预测效果还可以,对于多音字"厦"预测,这个特别容易出错,这几个句子都会读成xia4
通过西门来访者可以进入大厦。
沈阳皇朝万鑫国际大厦

请问这块是因为实际训练集的影响,还是其它原因呢?看论文实际训练多音字是432个,方便问下具体是哪些多音字吗?

新增調用 GPU 推理功能

調用 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']

理論上只須修改此行

self.session_g2pw = onnxruntime.InferenceSession(os.path.join(model_dir, 'g2pw.onnx'), sess_options=sess_options)

self.session_g2pw =  onnxruntime.InferenceSession(os.path.join(model_dir, 'g2pw.onnx'), sess_options=sess_options,providers=['CUDAExecutionProvider'])

Include g2pW into PaddleSpeech TTS

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:

“和”字拼音转成了han4

conv = G2PWConverter(style='pinyin', enable_non_tradional_chinese=True)

conv('我和你')
[['wo3', 'han4', 'ni3']]

如上图, 测试发现“和”字拼音转成了han4

diff between minnan and mandarin

头发

  • minnan: 头发(fa3)
  • mandarin: 头发(fa4)

拥抱

  • minnan: 拥(yong3)抱
  • mandarin: 拥(yong1)抱

.. 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:
image

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

模型训练问题——简体/繁体

感谢您的工作!
我最近想要重新训练一下g2pW模型,但是我在看issue和cpp_dataset中的数据时有一个问题,在issue中好像讨论的都是当下的模型是基于繁体中文来训练的;而cpp_dataset中的数据却都是简体中文;那么整体训练过程到底是使用了简体还是繁体呢?

期待您的回复。

The length of input could not more than 16?

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?

multiprocessing error

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年以后,他竟退出了大家的视线。')

predict_g2p_bert.py报错

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

模型大小不一样

您提供的checkpoints,大小是600M;
用您的代码跑出来的模型大小同400M。
请问这差的200M,是啥原因导致的呀?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.