There is another confusing phrase I got.
気づけば思わず呟いていた
I translated it like: I noticed suddenly, what I spontaneously started to sing.
But why there is conditional "ba" in 気づけば?