generated from opentensor/bittensor-subnet-template
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from 0X0StradSong/main
New dataset: p239
- Loading branch information
Showing
8 changed files
with
226 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pandas as pd | ||
import wave | ||
import os | ||
from glob import glob | ||
from tqdm import tqdm | ||
df_paths = glob('data/*.parquet') | ||
|
||
def save_audio(row, file_name): | ||
audio_bytes = row['audio']['bytes'] | ||
|
||
# Convert bytes to wave format and save | ||
with wave.open(file_name, 'wb') as wave_file: | ||
wave_file.setnchannels(1) # Mono | ||
wave_file.setsampwidth(2) # Assuming 16-bit PCM | ||
wave_file.setframerate(88200) # Assuming a sample rate of 16000 Hz | ||
wave_file.writeframes(audio_bytes) | ||
|
||
voice_counters = {} | ||
|
||
for df_path in df_paths: | ||
df = pd.read_parquet(df_path) | ||
for index, row in tqdm(df.iterrows()): | ||
voice = int(row['voice']) | ||
voice_str = f"p_{voice:03d}" | ||
if voice_str not in voice_counters: | ||
voice_counters[voice_str] = 0 | ||
caption = row['caption'] | ||
# mkdir if not exists | ||
txt_dir = f"txt/{voice_str}" | ||
os.makedirs(txt_dir, exist_ok=True) | ||
# save caption | ||
with open(f"{txt_dir}/{voice_str}_{voice_counters[voice_str]:03d}.txt", 'w') as f: | ||
f.write(caption) | ||
# mkdir if not exists | ||
audio_dir = f"wave/{voice_str}" | ||
os.makedirs(audio_dir, exist_ok=True) | ||
# save audio | ||
save_audio(row, f"{audio_dir}/{voice_str}_{voice_counters[voice_str]:03d}_mic1.wav") | ||
voice_counters[voice_str] += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# Base URL for the files | ||
base_url="https://huggingface.co/datasets/ShoukanLabs/AniSpeech/resolve/main/data/ENGLISH-000" | ||
|
||
# Directory to save the downloaded files | ||
output_dir="./data" | ||
mkdir -p "$output_dir" | ||
|
||
# Download files from 00000 to 00037 | ||
for i in $(seq -w 0 37); do | ||
file_url="${base_url}${i}-of-00038.parquet?download=true" | ||
output_file="${output_dir}/ENGLISH-000${i}-of-00038.parquet" | ||
|
||
echo "Downloading ${output_file}..." | ||
wget -O "$output_file" "$file_url" | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Failed to download ${output_file}" | ||
else | ||
echo "Successfully downloaded ${output_file}" | ||
fi | ||
done | ||
|
||
echo "Download completed." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.