SurDetector.pyIl y a des questions.
Closed this issue · 2 comments
Bonjour, les documents suivants sont traduits en automatique。
debut = np.where(frequencies > 0)[0][0]
fin = np.where(frequencies > 1050)[0][0]
freq = frequencies[debut:fin]
amp = abs(fourier.real[debut:fin])
lf = freq[np.where(amp == max(amp))[0][0]]
delta = args.t
best = 0
for f in [695, 766, 846, 934]:
if abs(lf-f) < delta:
delta = abs(lf-f)
best = f
lf = best
En tant qu'autodidacte, il a fallu beaucoup de temps pour lire et comprendre les implications
Pouvez-vous expliquer la signification du code ci-dessus ? Merci beaucoup !
Hi,
Thanks for your interest, I'll try to speak English, I guess it's easier for you ^^
"début" and "fin" are French words, I'm sorry. I've corrected that:
frequencies = np.fft.fftfreq(signal.size, d=1/fps)
amplitudes = np.fft.fft(signal)
# Low
i_min = np.where(frequencies > 0)[0][0]
i_max = np.where(frequencies > 1050)[0][0]
freq = frequencies[i_min:i_max]
amp = abs(amplitudes.real[i_min:i_max])
lf = freq[np.where(amp == max(amp))[0][0]]
delta = args.t
for f in [697, 770, 852, 941]:
if abs(lf-f) < delta:
delta = abs(lf-f)
best = f
lf = best
We compute a Fourier Transform on our sample to find its frequencies. frequencies
contains a list of 326 frequencies from -4000 to 4000 Hz and amplitudes
contains the relative amplitudes of these 326 frequencies (in the same order). i_min
is the first index in these lists where the frequency is greater than 0 Hz and i_max
the first index where the frequency is greater than 1050 Hz. There are arbitrary values chosen to contain the lower frequencies of the DTMF (697, 770, 852 and 941 Hz).
freq = frequencies[i_min:i_max]
and amp = abs(amplitudes.real[i_min:i_max])
crop the lists and we store the frequency with the higher amplitude in this range into lf
. After that, we search which of the four frequencies of DTMF is the closest to lf
.
Thank you, brother, for helping me with a problem that is currently difficult for me to solve. Thank you very much, and here's sending you my sincere wishes for your patient answers so that I can better understand the implications.
十分感谢,帮助了我完成了一个目前对于我来说难以解决的问题。在这里,向你送上诚挚的祝福,感谢你的耐心解答让我能够更好的理解其中的含义。