Almost periodic sequences with respect to orthogonal polynomials