This is specially for those who want to sing Chinese song in karaoke. Recently I like to listen to Jay Chou ‘s song in his latest album ‘Exclamation Mark’, especially 水手怕水(Sailor scare of water) & 皮影戏. I get a lyrics player – 千千静听 then load the lyric file so it can display the lyric while I play the song.
Initially I try to copy paste whole content at Google translate and try to get the result what I want. But it do the proper translate of course you can get the pronunciation when you press the voice button. However this cannot be printed and bring into Karaoke room when you want to sing it. My solution is get a unicode-pinyin library at uc-to-py.tbl then created a very simple parser to convert Chinese character to pinyin pronunciation.
[00:03.41]叫我 水手 oh oh come on come on baby
|[00:00.00]shui3 shou3 pa4 shui3 —zhou1 jie2 lun2
[00:02.23]da4 hai3 zhen1 ke3 pa4
[00:03.41]jiao4 wo3 shui3 shou3 oh oh come on come on baby
[00:06.83]mei3 ren2 yu2 gou1 yin3 wo3 zhei4 zhao1 bei1 bi3
The library source is something like this
I create a dictionary collection to hold a character with the corresponding pinying value.
Dictionary<char, string> libs = new Dictionary<char, string>(); ... char key = '\0';//default empty char int keyValue = Convert.ToInt32("4E00", 16); key = (char)keyValue;//cast to unicode character libs.Add(key, "ling2"); ...
You can imagine the collection is holding
It is a console app. Put the 2 files together and your lrc or text file gonna be convert. Remember to backup your source file. It will directly overwrite the source file after conversion.
TODO: Enhancement convert Japanese Hirakana or Korean Hangul to roman character so we can sing Wonder Girls – ‘Nobody’ and Girl Generation – ‘Mr. Taxi Taxi’ 🙂