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)
| 272 | |
| 273 | |
| 274 | def 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 | |
| 292 | def mel_to_freq(mels: float) -> float: |