A train travelling from Thailand's capital has derailed after a construction crane fell on one of its carriages, killing 12 people and injuring at least 30.