Spaces:
Running
Running
sample debug
Browse files- datahandler.py +8 -0
datahandler.py
CHANGED
|
@@ -10,9 +10,17 @@ import librosa
|
|
| 10 |
def fix_audio_format(audio_path, out_sr=16000):
|
| 11 |
|
| 12 |
data, sr = librosa.load(audio_path, sr=out_sr, mono=True)
|
|
|
|
| 13 |
|
| 14 |
return data
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
class AudioMixer(object):
|
| 17 |
def __init__(
|
| 18 |
self,
|
|
|
|
| 10 |
def fix_audio_format(audio_path, out_sr=16000):
|
| 11 |
|
| 12 |
data, sr = librosa.load(audio_path, sr=out_sr, mono=True)
|
| 13 |
+
print("sample:",sr)
|
| 14 |
|
| 15 |
return data
|
| 16 |
|
| 17 |
+
def convert_audio_to_wav(file_path):
|
| 18 |
+
"""Convert any supported format (mp3, etc.) to wav using librosa"""
|
| 19 |
+
output_path = "temp_input.wav"
|
| 20 |
+
audio, sr = librosa.load(file_path, sr=None) # Load file (wav, mp3, etc.)
|
| 21 |
+
librosa.output.write_wav(output_path, audio, sr) # Convert to wav
|
| 22 |
+
return output_path
|
| 23 |
+
|
| 24 |
class AudioMixer(object):
|
| 25 |
def __init__(
|
| 26 |
self,
|