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

Function normalize

machine_learning/mfcc.py:152–171  ·  view source on GitHub ↗

Normalize an audio signal by scaling it to have values between -1 and 1. Args: audio: The input audio signal. Returns: The normalized audio signal. Examples: >>> audio = np.array([1, 2, 3, 4, 5]) >>> normalized_audio = normalize(audio) >>> float(np.max

(audio: np.ndarray)

Source from the content-addressed store, hash-verified

150
151
152def normalize(audio: np.ndarray) -> np.ndarray:
153 """
154 Normalize an audio signal by scaling it to have values between -1 and 1.
155
156 Args:
157 audio: The input audio signal.
158
159 Returns:
160 The normalized audio signal.
161
162 Examples:
163 >>> audio = np.array([1, 2, 3, 4, 5])
164 >>> normalized_audio = normalize(audio)
165 >>> float(np.max(normalized_audio))
166 1.0
167 >>> float(np.min(normalized_audio))
168 0.2
169 """
170 # Divide the entire audio signal by the maximum absolute value
171 return audio / np.max(np.abs(audio))
172
173
174def audio_frames(

Callers 1

mfccFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected