Installing OpenFST on Mac OS X Leopard

http://www.openfst.org/twiki/bin/view/FST/CompilingOnMacOSX

It turns out the default compiler gcc4.0 has a bug (or many bugs?) that makes compiling openfst on Leopard fail. The above link which is taken from openfst website solves the problem

Setting Vim configurations

Under mac os X, the vim has no syntax highlights and no history from the last vim session. This can be solved using the following steps:

1) make a file under home folder named .vimrc

2) syntax on; set history=1000

3)chmod 777 ~/.viminfo

Terminal colors under Mac OS X

There is no color highlight under mac os x terminal by default which I think it a bit annoying since there is no way of distinguishing folders and files. After some research on the internet, I found some solutions (credit: http://stackoverflow.com/questions/1550288/mac-os-x-terminal-colors ):

You can use the Linux based syntax in one of your startup scripts as well. eg. in your ~/.bash_profile

export TERM="xterm-color"
PS1='\[\033[1;32m\]\u\[\033[0m\]@\[\033[1;31m\]\h\[\033[0m\]:\[\033[1;34m\]\w\[\033[0m\]\$ '

This gives you a nice colored prompt. To add the colored ls output, you can add alias ls="ls -G" as well.

To test, just run a source ~/.bash_profile to update your current terminal.

Sidenote about the colors: The colors are defined by an escape sequence \033 and the color value, composed of [style;color+m] wrapped in an escaped [] sequence. eg.

  • red = \[\033[0;31m]\]
  • bold red (style 1) = \[\033[1;31m]\]
  • clear coloring = \[\033[0m]\]

I always add a slightly modified color-scheme in the root’s .bash_profile to make the username red, so I always see clearly if I’m logged in as root (handy to avoid mistakes if you have many terminal windows open)

in /root/.bash_profile

PS1='\[\033[0;31m\]\u\[\033[0m\]@\[\033[0;32m\]\h\[\033[0m\]:\[\033[0;34m\]\w\[\033[0m\]\$ '

For all my SSH accounts online I make sure to put the hostname in red, to be able to distinguish more easily if I’m in a local or remote terminal..

SGE Installation problem on Suse

The SoC network is very unstable, it crashes a lot. What’s worse is that the Cent OS on my server CANNOT reconnect to the network even if the network is on. Therefore, I had to come down to the server room to MANUALLY re-activate the damn network interface. Because of the DHCP thing, the sge installed will be malfunctioning because it replies on /etc/hosts to work properly and after a network crash, the allocated IP address has been changed. Followings are the approaches to fix this:

  1. Log in as root
  2. ifconfig get the ip address
  3. vi /etc/hosts, update the ip address
  4. /etc/init.d/network restart # restart the network
  5. cd into the sge install folder
  6. ps aux|grep sge to find the PID of sge_qmaster and sge_execd process and KILL THEM BEFORE INSTALLING
  7. start install sge, all by default except remember to select NO when prompted to install a startup script. Choose yes will cause problem when restarting the server because during starting, the IP address is again changed, i.e., sge does not work. Trying to start the sge process will block the startup process for almost AN HOUR. In other words, the restarting will take almost an hour.
  8. Voila. Good to go

Fix “machine `x86_64-unknown’ not recognized” configuration error

I finally registered a high performance computing account of my University and tried to set my experiments using the computing facilities which are supposedly superb.

I got one error when installing “dpwelib-2009-02-24″. During configuration, I got an error saying “checking build system type… Invalid configuration `x86_64-unknown-linux’: machine `x86_64-unknown’ not recognized”, which means the machine is not recognized. The problem is solved by specifying “–build=x86-64″ with the configuration.

Argmin in LaTeX

Credit: http://www.breakthru.altervista.org/?p=27

Today I was writing a report and as usual I was searching the web

for quick solutions of common things like: how do I write the min over some
variables of some function in a LaTeX formula?
Search engines found for me many pages that were saying “there is explanation
for this on wikipedia” BUT.. that wiki page had changed!!!
It’s like linking a wrong page… interesting stuff.
Anyway this is the trick, taken from the history of the wiki (always great thing)

LaTeX has no built-in ”’\argmax”’ command. Some people get around this by using ”’\arg\max”’. This could be undesirable, because a subscripted variable will appear centered beneath the word “max”, instead of centered beneath the whole word.
An easy solution is to use: \underset{x}{\operatorname{argmax}}

Enjoy LaTeX!

Happy Hacking

Adjusting Logo position in Beamer

Beamer is great tool for preparing serious ppt.

I am busy preparing the slides for my conference presentation these days. Finally finished the main content and want to add the University logo to the slides, however, the manual of beamer says that the \logo command can only put the logo on the bottom right corner of one slide which is not suitable for my slides, since most slides  cover the right bottom corner. Therefore, I need to move the logo to the upper right corner.

After an afternoon’s trial and error and research, finally got it done:

  1. \usepackage{pgf}
  2. before \begin{document}, add “\logo{\pgfputat{\pgfxy(-0.8,7.85)}{\pgfbox[center,base]{\includegraphics[height=0.7cm]{NUS.eps}}}}”, Note for your own needs, you need to tune the \pgfxy(-0.8,7.85) parameter which is the coordination of the logo, and the size  [height=0.7cm]
  3. Note the theme of the beamer will color the title of each frame with the color defined in the theme, however, chances are that the background color will cover the logo, therefore, the background color of the theme should be removed for the logo to appear on each slides by ”
    \setbeamercolor{background canvas}{bg=}
    \setbeamercolor{frametitle}{bg=}

  4. cross your finger and hope it works (well at least it works for me)

Printing under Mac OS X in NUS

Credit: http://zitseng.com/mac/mac-nus-part-1
1. Start System Preferences.
2. Click on Print & Fax.
3. Click the + sign.
4. If there is no Advanced button in the toolbar, you may have to add it there before continuing. Right-click the toolbar (or Control-Click), then drag and drop the Advanced button to the toolbar.
5. For Type, select Windows.
6. The URL is the complicated bit. Make sure you get this right. The URL has the following format: smb://: @nusstu/nts27.comp.nus.edu.sg/ where is your NUSNET account name

is your NUSNET account password
change nts27 to nts09 for staff users

is the queue name of the printer which you can find listed at SoC Printers and Print Queues.
7. For Name, enter anything you fancy to help you remember what print queue this is.
8. Same for Location, whatever you fancy.
9. For Print Using box, choose either the Generic PostScript Printer driver, or select the specific printer driver for the print queue. You can find the list of printer types at SoC Printers and Print Queues.
10. Click Add.
11. Usually fine to leave the option settings unchanged.
12. Click Continue.

Lattice rescoring with HDecode

There could be cases that the acoustic models are updated frequently and you want to see the performance of each update, therefore, you have to do a word recognition which is very time consuming.

HDecode supports both full decoding with a language model up to Bigram and lattice rescoring with the existing lattices. Full decoding can produce a set of lattices with a lower order language model, HLRescore can be applied to expand these lattices with a higher order language model to get an improved  recognition result or/and a set of new lattices rescored with the higher order language model.

Assuming we have a set of lattices generated by HDecode with a bigram full decoding which are stored under lat_bg, and we have a compressed trigram language model, tg_lm.gz, we can get a 1-best path in the lattice after applying the trigram language model by issuing the following command:

 HLRescore -C config.hlrescore -S test.lcp \
          -f -i recout_tg.mlf -n tg_lm -L lat_bg -w -l lat_tg \
          -p 0.0 -s 5.0 dict.hdecode

The 1-best result is stored as recount_tg.mlf, In addition, compressed version of the lattices now with trigram language model are stored  in lat_tg.

It is then possible to rescore these trigram lattices using HDecode with either a different set of acoustic models, or a different grammar scale factor. However, prior to this it is again necessary to ensure that the lattices are deterministic. Thus the following command is required:

HLRescore -C config.hlrescore -S test.lcp \
          -t 200.0 1000.0 -m f -L lat_tg \
          -w -l lat_tg_det dict.hdecode

These lattices can then be rescored using:

 HDecode -H hmm21/models -S test.scp \
          -t 220.0 220.0 -w \
          -C config.hdecode -i recout_rescore.mlf -L lat_tg_det \
          -p 0.0 -s 5.0 dict.hdecode xwrdtiedlist2

where the new set of acoustic models are assumed to be stored in hmm21/models and model-list in xwrdtiedlist2. NOTE THERE IS A MISTAKE IN HTK BOOK, THE -w option is missed in 3.9.5

Credit: HTK Book 3.9.5

Thanks for all your support

Too busy these days, I have almost forgot I have a word press which I once thought I would update once a day.

Out of no reason, I opened it today and found there were many encouraging comments under one of my post, although I don’t know these bloggers, I am quite moved, never thought what I did would help so many people.

Yeah, I should continue writing this blog, just as the profile says  “在这里留下青春和奋斗的痕迹,致我们终将逝去的青春。”

Stay tuned, thanks for you all!!