Example function to calculate Mel Frequency Cepstral Coefficients (MFCCs) from an audio file. Args: wav_file_path: The path to the WAV audio file. Returns: np.ndarray: The computed MFCCs for the audio.
(wav_file_path: str = "./path-to-file/sample.wav")
| 454 | |
| 455 | |
| 456 | def example(wav_file_path: str = "./path-to-file/sample.wav") -> np.ndarray: |
| 457 | """ |
| 458 | Example function to calculate Mel Frequency Cepstral Coefficients |
| 459 | (MFCCs) from an audio file. |
| 460 | |
| 461 | Args: |
| 462 | wav_file_path: The path to the WAV audio file. |
| 463 | |
| 464 | Returns: |
| 465 | np.ndarray: The computed MFCCs for the audio. |
| 466 | """ |
| 467 | from scipy.io import wavfile |
| 468 | |
| 469 | # Load the audio from the WAV file |
| 470 | sample_rate, audio = wavfile.read(wav_file_path) |
| 471 | |
| 472 | # Calculate MFCCs |
| 473 | return mfcc(audio, sample_rate) |
| 474 | |
| 475 | |
| 476 | if __name__ == "__main__": |