"tutorials/cpu/argo_tutorial.py" did not exist on "9d9e223783865b5f3fba98af921db4509c0d5069"
Unverified Commit 2c07658b authored by moto's avatar moto Committed by GitHub
Browse files

Make VCTK_092 return regular type for the consistency (#949)

parent c92392fc
import os import os
import warnings import warnings
from typing import Any, Tuple from typing import Any, Tuple
from collections import namedtuple
import torchaudio import torchaudio
from torch import Tensor from torch import Tensor
...@@ -18,10 +17,6 @@ _CHECKSUMS = { ...@@ -18,10 +17,6 @@ _CHECKSUMS = {
"https://datashare.is.ed.ac.uk/bitstream/handle/10283/3443/VCTK-Corpus-0.92.zip": "8a6ba2946b36fcbef0212cad601f4bfa" "https://datashare.is.ed.ac.uk/bitstream/handle/10283/3443/VCTK-Corpus-0.92.zip": "8a6ba2946b36fcbef0212cad601f4bfa"
} }
Sample = namedtuple(
"Sample", ["waveform", "sample_rate", "utterance", "speaker_id", "utterance_id"]
)
def load_vctk_item(fileid: str, def load_vctk_item(fileid: str,
path: str, path: str,
...@@ -163,6 +158,9 @@ class VCTK(Dataset): ...@@ -163,6 +158,9 @@ class VCTK(Dataset):
return len(self._walker) return len(self._walker)
SampleType = Tuple[Tensor, int, str, str, str]
class VCTK_092(Dataset): class VCTK_092(Dataset):
"""Create VCTK 0.92 Dataset """Create VCTK 0.92 Dataset
...@@ -253,7 +251,7 @@ class VCTK_092(Dataset): ...@@ -253,7 +251,7 @@ class VCTK_092(Dataset):
def _load_audio(self, file_path) -> Tuple[Tensor, int]: def _load_audio(self, file_path) -> Tuple[Tensor, int]:
return torchaudio.load(file_path) return torchaudio.load(file_path)
def _load_sample(self, speaker_id: str, utterance_id: str, mic_id: str) -> Sample: def _load_sample(self, speaker_id: str, utterance_id: str, mic_id: str) -> SampleType:
utterance_path = os.path.join( utterance_path = os.path.join(
self._txt_dir, speaker_id, f"{speaker_id}_{utterance_id}.txt" self._txt_dir, speaker_id, f"{speaker_id}_{utterance_id}.txt"
) )
...@@ -269,9 +267,9 @@ class VCTK_092(Dataset): ...@@ -269,9 +267,9 @@ class VCTK_092(Dataset):
# Reading FLAC # Reading FLAC
waveform, sample_rate = self._load_audio(audio_path) waveform, sample_rate = self._load_audio(audio_path)
return Sample(waveform, sample_rate, utterance, speaker_id, utterance_id) return (waveform, sample_rate, utterance, speaker_id, utterance_id)
def __getitem__(self, n: int) -> Sample: def __getitem__(self, n: int) -> SampleType:
"""Load the n-th sample from the dataset. """Load the n-th sample from the dataset.
Args: Args:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment