We demonstrate here for the first time generation of tunable terahertz (THz) radiation based on photomixing continuous wave (CW) radiation of the DFB laser with fixed wavelength and self-sweeping Er-doped fiber one operating near 1560 nm. The latter sequentially generates longitudinal modes with duration of several milliseconds and regular hopping between them. In this case signal accumulation of THz radiation within generation of each mode can be performed to increase signal-to-noise ratio (SNR). We demonstrated the possibility of designing a spectrometer with spectral resolution down to 50 MHz in the tuning range of ~5 GHz near the central frequency of 100 GHz. The proposed approach can be useful in the development of spectroscopic systems, millimeter-wave lidars, and telecom devices.