Spaces:
No application file
No application file
File size: 511 Bytes
0d5c993 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import librosa
import numpy as np
TARGET_SR = 16000
def load_audio(file_path):
audio, sr = librosa.load(file_path, sr=TARGET_SR)
return audio
def normalize_audio(audio):
audio = audio / np.max(np.abs(audio))
return audio
def remove_silence(audio):
intervals = librosa.effects.split(audio, top_db=30)
segments = []
for start, end in intervals:
segments.append(audio[start:end])
if len(segments) == 0:
return audio
return np.concatenate(segments) |