A generalized telegraph process with velocity driven by random trials