éçºç°å¢
- python 3.9
- uv
ã»ããã¢ãã
ã©ã¤ãã©ãªãã¤ã³ã¹ãã¼ã«ãã¾ã
uv pip install datasets[audio] soundfile pydub
å®è¡
以ä¸ã§ãã¼ã¿ã»ããããã¦ã³ãã¼ããã¦ãwavå½¢å¼ã§ä¿åãã¾ã
from datasets import load_dataset import soundfile as sf # wavãã¡ã¤ã«ã®ä¿åã«ä½¿ç¨ from pydub import AudioSegment # mp3ãã¡ã¤ã«ã®ä¿åã«ä½¿ç¨ import os # æ¥æ¬èªã®ãã¼ã¿ã»ããããã¼ã ds = load_dataset("diarizers-community/callhome", "jpn", split='data') # ä¿åå ã®ãã£ã¬ã¯ããªãæå® output_dir = "callhome_japanese_audio" os.makedirs(output_dir, exist_ok=True) # é³å£°ãã¼ã¿ãã«ã¼ããã¦ä¿å for idx, example in enumerate(ds): # é³å£°ãã¼ã¿ã®åå¾ audio = example['audio'] array = audio['array'] sampling_rate = audio['sampling_rate'] # ãã¡ã¤ã«åãä½æ filename_base = f"callhome_jpn_{idx}" # wavãã¡ã¤ã«ã¨ãã¦ä¿å wav_path = os.path.join(output_dir, f"{filename_base}.wav") sf.write(wav_path, array, sampling_rate) print(f"Saved WAV file: {wav_path}")