MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / freq_to_mel

Function freq_to_mel

machine_learning/mfcc.py:274–289  ·  view source on GitHub ↗

Convert a frequency in Hertz to the mel scale. Args: freq: The frequency in Hertz. Returns: The frequency in mel scale. Examples: >>> float(round(freq_to_mel(1000), 2)) 999.99

(freq: float)

Source from the content-addressed store, hash-verified

272
273
274def freq_to_mel(freq: float) -> float:
275 """
276 Convert a frequency in Hertz to the mel scale.
277
278 Args:
279 freq: The frequency in Hertz.
280
281 Returns:
282 The frequency in mel scale.
283
284 Examples:
285 >>> float(round(freq_to_mel(1000), 2))
286 999.99
287 """
288 # Use the formula to convert frequency to the mel scale
289 return 2595.0 * np.log10(1.0 + freq / 700.0)
290
291
292def mel_to_freq(mels: float) -> float:

Callers 1

get_filter_pointsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected