File size: 726 Bytes
728b833
388a1c1
 
 
 
 
 
 
 
 
 
 
df218d3
 
 
 
728b833
 
 
 
 
 
 
df218d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# pip install numpy==1.26.4 torchaudio==0.13.1 transformers==4.45.2 datasets==3.0.1 librosa==0.10.2.post1 jiwer==3.0.4 bitsandbytes==0.38.0.post1 accelerate==0.26.0

dataset_name = "dlxjj/common_voice_17_0"
language = "Japanese"
language_abbr = "ja"

from datasets import load_dataset, DatasetDict

common_voice = DatasetDict()

common_voice["train"] = load_dataset(dataset_name, language_abbr, split="train", trust_remote_code=True)

print(common_voice["train"][0])

array = common_voice["train"][0]["audio"]["array"]

import torch, numpy as np, torchaudio
 
tensor = torch.tensor(np.array( array, dtype='float32'))

sampling_rate = 48000
torchaudio.save("t.wav", tensor.unsqueeze(0), sampling_rate, bits_per_sample=16)

pass