Spaces:
Sleeping
Sleeping
File size: 703 Bytes
619d4a2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
"""Convert audio to other formats"""
from pydub import AudioSegment
import librosa
import soundfile as sf
from modules.console_colors import ULTRASINGER_HEAD
def convert_audio_to_mono_wav(input_file_path: str, output_file_path: str) -> None:
"""Convert audio to mono wav"""
print(f"{ULTRASINGER_HEAD} Converting audio for AI")
y, sr = librosa.load(input_file_path, mono=True, sr=None)
sf.write(output_file_path, y, sr)
def convert_wav_to_mp3(input_file_path: str, output_file_path: str) -> None:
"""Convert wav to mp3"""
print(f"{ULTRASINGER_HEAD} Converting wav to mp3")
sound = AudioSegment.from_wav(input_file_path)
sound.export(output_file_path, format="mp3")
|