MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / example

Function example

machine_learning/mfcc.py:456–473  ·  view source on GitHub ↗

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")

Source from the content-addressed store, hash-verified

454
455
456def 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
476if __name__ == "__main__":

Callers

nothing calls this directly

Calls 1

mfccFunction · 0.85

Tested by

no test coverage detected