npm install chinese-to-pinyin --save
npm start
npm test
npm run build
var pinyin = require("chinese-to-pinyin")
pinyin('中文语句')
pinyin('今天天气真好') // jīn tiān tiān qì zhēn hǎo
pinyin('蚌埠六安哪吒都灵') // bèng bù lù ān né zhā dū líng
pinyin('今天天气真好', {removeTone: true}) // jin tian tian qi zhen hao
pinyin('今天天气真好', {toneToNumber: true}) // jin1 tian1 tian1 qi4 zhen1 hao3
pinyin('今天天气真好', {toneToNumberOnly: true}) // 1 1 1 4 1 3
pinyin('今天天气真好', {removeSpace: true}) // jīntiāntiānqìzhēnhǎo
pinyin('1今天天气dd dd真e好fff', { keepRest: true }) // 1jīn tiān tiān qìdd ddzhēnehǎofff
pinyin('今天天气真好', { firstCharacter: true }) // j t t q z h
// 获取中文首字母时,保留未翻译的非中文字符
pinyin('1今2天3天4气5真6好aaa', { keepRest: true, firstCharacter: true }) // 1j2t3t4q5z6haaa
// 获取中文首字母时,不保留未翻译的非中文字符
pinyin('1今2天3天4气5真6好aaa', { firstCharacter: true }) // j t t q z h