Spaces:
Sleeping
Sleeping
File size: 1,570 Bytes
b1fdcc2 4c92361 c88f061 e3a6fa0 2e3ca25 141bd52 b1fdcc2 e3a6fa0 b1fdcc2 b0a9f8f 4c92361 b0a9f8f 4c92361 b0a9f8f 4c92361 b0a9f8f |
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
#!/bin/bash
echo "Starting prepare_samples.sh..."
# Read the secret into a variable
export PREPARE_SAMPLES=$(cat /run/secrets/PREPARE_SAMPLES)
# Check if the "PREPARE_SAMPLES" environment variable is set
if [ -z "${PREPARE_SAMPLES}" ]; then
echo "PREPARE_SAMPLES is unset or set to the empty string. Skipping sample preparation."
exit 0
fi
# Read JSON file into a variable
json=$(cat sample_songs.json)
mkdir -p "/tmp/vocal_remover"
# Iterate through keys and values
for name in $(echo "${json}" | jq -r 'keys[]'); do
url=$(echo "${json}" | jq -r --arg name "${name}" '.[$name]')
echo "Separating ${name} from ${url}"
# Download with pytube
yt-dlp ${url} -o "/tmp/${name}" --format "bestaudio/best"
# Run inference
python inference.py --input /tmp/${name} --output /tmp
echo "Done separating ${name}"
done
# Read JSON file into a variable
json_separate=$(cat separate_songs.json)
# Iterate through keys and values
for name in $(echo "${json_separate}" | jq -r 'keys[]'); do
url=$(echo "${json_separate}" | jq -r --arg name "${name}" '.[$name][0]')
start_time=$(echo "${json_separate}" | jq -r --arg name "${name}" '.[$name][1]')
end_time=$(expr $start_time + 20)
echo "Separating ${name} from ${url} with start_time ${start_time} sec"
# Download with pytube
yt-dlp ${url} -o "/tmp/${name}" --format "bestaudio/best" --download-sections "*${start_time}-${end_time}"
# Run inference
python inference.py --input /tmp/${name} --output /tmp --full_mode 1
echo "Done separating ${name}"
done
|