一个将中文翻译成拼音的库,支持多音字
npm install chinese-to-pinyin
clone 至本地调试代码的时候建议开启 grunt 以便监听改动实时编译
grunt
var pinyin = require("chinese-to-pinyin");
pinyin('今天天气真好'); // jīn tiān tiān qì zhēn hǎo
var pinyin = require("chinese-to-pinyin");
pinyin('蚌埠六安哪吒都灵'); // bèng bù lù ān né zhā dū líng
var pinyin = require("chinese-to-pinyin");
pinyin('今天天气真好', {noTone: true}); // jin tian tian qi zhen hao
var pinyin = require("chinese-to-pinyin");
pinyin('今天天气真好', {numberTone: true}); // jin1 tian1 tian1 qi4 zhen1 hao3
var pinyin = require("chinese-to-pinyin");
pinyin('1今a天bb天ccc气dd dd真e好fff', {filterChinese: true}); // 1 jīn a tiān bb tiān ccc qì dd dd zhēn e hǎo fff