I've been to both cities many times, usually from one to the other and back on a long trip to Asia from the US.
I would choose Taipei. When I fly from Shanghai to Taipei I'm always struck by the difference. In Taipei - cleaner air and streets; bigger, cleaner taxies; better food in general; and a more compact city with close and quick access to activities outside the city in the surrounding mountains.