Direct extraction of topological Zak phase with the synthetic dimension