You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
# MIT License, Copyright (c) 2023-Present, Descript.
|
|
# Copyright (c) 2025 PaddlePaddle Authors. All Rights Reserved.
|
|
#
|
|
# Modified from audiotools(https://github.com/descriptinc/audiotools/blob/master/tests/data/test_preprocess.py)
|
|
import sys
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
import paddle
|
|
|
|
from audio.audiotools.core.util import find_audio
|
|
from audio.audiotools.core.util import read_sources
|
|
from audio.audiotools.data import preprocess
|
|
|
|
|
|
def test_create_csv():
|
|
with tempfile.NamedTemporaryFile(suffix=".csv") as f:
|
|
preprocess.create_csv(
|
|
find_audio("././audio/spk", ext=["wav"]), f.name, loudness=True)
|
|
|
|
|
|
def test_create_csv_with_empty_rows():
|
|
audio_files = find_audio("././audio/spk", ext=["wav"])
|
|
audio_files.insert(0, "")
|
|
audio_files.insert(2, "")
|
|
|
|
with tempfile.NamedTemporaryFile(suffix=".csv") as f:
|
|
preprocess.create_csv(audio_files, f.name, loudness=True)
|
|
|
|
audio_files = read_sources([f.name], remove_empty=True)
|
|
assert len(audio_files[0]) == 1
|
|
audio_files = read_sources([f.name], remove_empty=False)
|
|
assert len(audio_files[0]) == 3
|