# \#audio-processing

**URL:** https://discuss.pytorch.kr/tag/audio-processing/2780.md

[최신](https://discuss.pytorch.kr/latest.md) · [카테고리](https://discuss.pytorch.kr/categories.md) · [태그](https://discuss.pytorch.kr/tags.md)

---

## [melspectrogram 생성 시 fft 대신 dct를 사용하여 음성처리](https://discuss.pytorch.kr/t/melspectrogram-fft-dct/3831)

<div class="topic-metadata">

**Author:** [@ojun.kwon](https://discuss.pytorch.kr/u/ojun.kwon)\
**댓글:** 5\
**마지막 업데이트:** [3월 27, 2024, 2:15오전 UTC](https://discuss.pytorch.kr/t/melspectrogram-fft-dct/3831 "2024-03-27T02:15:20Z")

</div>

torchaudio.transforms.MelSpectrogram 으로 멜 스펙트로그램 생성시 STFT과정에서 FFT를 사용함 이러한 STFT를 Short-Time Discrete Cosine Transform, 즉 DCT를 사용한 변환으로 바꾸어 스펙트로그램을 생성하고 멜스케일을 적용하여 멜 스펙트로 그램을 생성하도록 수정하고자함 (DCT는 실수 연산으로 복소연산보다 1/2배의 연산량 이점이 있음) 아래 코드는 STFT에 FFT 대신 DCT를 사용한 Spectrogram 생성 코드임 import librosa import scipy import numpy as np def sdct(signal, frame\_length, frame\_step, window="hamming"): """Compute Short-Time Discrete Cosine Transform of \`signal\`. No padding is applied to the signals. Parameters ---------- signal : Time-domain input signal of shape \`(n\_samples,)\`. frame\_length : Window length and DCT frame length in samples. frame\_step : Number of samples between adjacent DCT columns. window : Window specification passed to \`\`librosa.filters.get\_window\`\`. Default: "hamming". Window to use for DCT. Returns ------- dct : Real-valued F-T domain DCT matrix of shape \`(frame\_length, n\_frames)\` """ framed = librosa.util.frame(x=sig…
