Nonlinear filtering problem has important applications in various fields. One of the core issues in nonlinear filtering is to numerically solve the Duncan–Mortensen–Zakai (DMZ) equation, which is an evolution equation satisfied by the unnormalized conditional density of state process under noisy observations, in a real-time and memoryless manner. When the noise in observations is correlated to the state process, the DMZ equation we need to deal with is a second-order stochastic partial differential equation. In this paper, we will propose an algorithm to solve the DMZ equation in this case, based on Hermite–Galerkin spectral method. According to this method, the DMZ equation is converted into a system of linear stochastic differential equations generated by the observation process. The effects of different discretization schemes on this stochastic differential system will also be discussed. Moreover, rigorous convergence analysis of the algorithm is given under mild conditions. Numerical results show that the method proposed in this paper can provide an instantaneous and accurate estimation to the state process of the system.