Since more and more elderly people suffer from lower extremity movement problems, it is of great social significance to assist persons with motor dysfunction to walk independently again and reduce the burden on caregivers. The self-paced walking intention, which could increase the ability of self-control on the start and stop of motion, was studied by applying brain-computer interface (BCI) technology, a novel research field. The cerebral hemoglobin signal, which was obtained from 30 subjects by applying functional near-infrared spectroscopy (fNIRS) technology, was processed to detect self-paced walking intention in this paper. Teager-Kaiser energy was extracted at each sampling point for five sub-bands (0.0095 similar to 0.021 Hz, 0.021 similar to 0.052 Hz, 0.052 similar to 0.145 Hz, 0.145 similar to 0.6 Hz, and 0.6 similar to 2.0 Hz). Gradient boosting decision tree (GBDT) was then utilized to establish the detecting model in real-time. The proposed method had a good performance to detect the walking intention and passed the pseudo-online test with a true positive rate of 100% (80/80), a false positive rate of 2.91% (4822/165171), and a detection latency of 0.39 +/- 1.06 s. GBDT method had an area under the curve value of 0.944 and was 0.125 (p < 0.001) higher than linear discriminant analysis (LDA). The results reflected that it is feasible to decode self-paced walking intention by applying fNIRS technology. This study lays a foundation for applying fNIRS-based BCI technology to control walking assistive devices practically.