Convert Chinese lyric to pinyin

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:06.83]美人鱼勾引我这招 卑鄙
[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

3007 (ling2)
4E00 (yi1)
4E01 (ding1,zheng1)
4E02 (kao3)
4E03 (qi1)
4E04 (shang4,shang3)
4E05 (xia4)

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
[一: yi1]
[丁: ding1,zheng1]
[丂: kao3]
[七: qi1]

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’ 🙂

Schedule a download

Windows 7 schedule job now able to support Power Shell script which you can code in more complicated C# logic. I have a requirement want to download a source file (i.e. price list) from internet to my desktop everyday for some comparison or other purpose. It can be also download just a pure html file for reading novel episode everyday, hehe.. So, you must download the file then rename to other just in case overwrite the previous file.

//if you are behind proxy
$credentials = new-object System.Net.NetworkCredential('username','password');
$proxy = new-object System.Net.WebProxy('http://your-proxy:80');
$proxy.Credentials = $credentials;
$client = new-object System.Net.WebClient;
$client.Proxy = $proxy;
$file = 'filename'+(get-date).ToString('yyyyMMdd')+'.pdf';
ren 'G:\desktop\filename.pdf' $file

**join all lines into one line as the parameter input in schedule screen, and caution, the single line not recognize double quote, please use single quote in all your string input**