目录

torchaudio.datasets

所有数据集都是 torch.utils.data.Dataset 的子类,并实现了 __getitem____len__ 方法。因此,它们都可以传递给 torch.utils.data.DataLoader,该加载器可以使用 torch.multiprocessing 个工作进程并行加载多个样本。例如:

yesno_data = torchaudio.datasets.YESNO('.', download=True)
data_loader = torch.utils.data.DataLoader(yesno_data,
                                          batch_size=1,
                                          shuffle=True,
                                          num_workers=args.nThreads)

CMUARCTIC

class torchaudio.datasets.CMUARCTIC(root: Union[str, pathlib.Path], url: str = 'aew', folder_in_archive: str = 'ARCTIC', download: bool = False)[source]

CMU ARCTIC 创建数据集 [1]。

Parameters
  • root (strPath) – 数据集所在或下载的目录路径。

  • url (str, optional) – 要从中下载数据集的 URL,或要下载的数据集类型。 (默认值:"aew") 允许的类型值为 "aew""ahw""aup""awb""axb""bdl""clb""eey""fem""gka""jmk""ksp""ljm""lnh""rms""rxr""slp""slt"

  • folder_in_archive (str, optional) – 数据集的顶层目录。(默认值:"ARCTIC"

  • download (bool, optional) – 如果在根路径下未找到数据集,是否下载该数据集。(默认值:False)。

__getitem__(n: int)Tuple[torch.Tensor, int, str, str][source]

从数据集中加载第 n 个样本。

Parameters

n (int) – 要加载的样本的索引

Returns

(waveform, sample_rate, transcript, utterance_id)

Return type

(张量, 整数, 字符串, 字符串)

CMUDict

class torchaudio.datasets.CMUDict(root: Union[str, pathlib.Path], exclude_punctuations: bool = True, *, download: bool = False, url: str = 'http://svn.code.sf.net/p/cmusphinx/code/trunk/cmudict/cmudict-0.7b', url_symbols: str = 'http://svn.code.sf.net/p/cmusphinx/code/trunk/cmudict/cmudict-0.7b.symbols')[source]

CMU 发音词典 [2] (CMUDict) 创建数据集。

Parameters
  • root (strPath) – 数据集所在或下载的目录路径。

  • exclude_punctuations (bool, optional) – 启用时,排除标点符号的发音,例如 !EXCLAMATION-POINT#HASH-MARK

  • download (bool, optional) – 如果在根路径下未找到数据集,是否下载该数据集。(默认值:False)。

  • url (str, optional) – 要从中下载字典的 URL。 (默认值: "http://svn.code.sf.net/p/cmusphinx/code/trunk/cmudict/cmudict-0.7b")

  • url_symbols (str, optional) – 用于下载符号列表的 URL。 (默认值:"http://svn.code.sf.net/p/cmusphinx/code/trunk/cmudict/cmudict-0.7b.symbols"

__getitem__(n: int)Tuple[str, List[str]][source]

从数据集中加载第 n 个样本。

Parameters

n (int) – 要加载的样本的索引。

Returns

对应的单词和音素 (word, [phonemes]).

Return type

(字符串, List[字符串])

property symbols

一个音素符号列表,例如 AAAEAH

Type

列表[字符串]

COMMONVOICE

class torchaudio.datasets.COMMONVOICE(root: Union[str, pathlib.Path], tsv: str = 'train.tsv')[source]

CommonVoice 创建数据集 [3]。

Parameters
  • root (strPath) – 数据集所在目录的路径。 (存在 tsv 文件的位置。)

  • tsv (str, optional) – 用于构建元数据的 tsv 文件名,例如 "train.tsv", "test.tsv", "dev.tsv", "invalidated.tsv", "validated.tsv""other.tsv"。(默认值:"train.tsv"

__getitem__(n: int)Tuple[torch.Tensor, int, Dict[str, str]][source]

从数据集中加载第 n 个样本。

Parameters

n (int) – 要加载的样本的索引

Returns

(waveform, sample_rate, dictionary), 其中字典是根据以下键从 TSV 文件构建的:client_id, path, sentence, up_votes, down_votes, age, genderaccent

Return type

(张量, 整数, 字典[字符串, 字符串])

GTZAN

class torchaudio.datasets.GTZAN(root: Union[str, pathlib.Path], url: str = 'http://opihi.cs.uvic.ca/sound/genres.tar.gz', folder_in_archive: str = 'genres', download: bool = False, subset: Optional[str] = None)[source]

GTZAN 创建数据集 [4]。

注意

如果您计划使用此数据集发布结果,请参阅 http://marsyas.info/downloads/datasets.html

Parameters
  • root (strPath) – 数据集所在或下载的目录路径。

  • url (str, optional) – 下载数据集的 URL。 (默认值: "http://opihi.cs.uvic.ca/sound/genres.tar.gz")

  • folder_in_archive (str, optional) – 数据集的顶层目录。

  • download (bool, optional) – 如果在根路径下未找到数据集,是否下载该数据集。(默认值:False)。

  • subset (strNone, 可选) – 要使用的数据集子集。 可以是 "training""validation""testing"None 之一。 如果为 None,则使用整个数据集。(默认值:None)。

__getitem__(n: int)Tuple[torch.Tensor, int, str][source]

从数据集中加载第 n 个样本。

Parameters

n (int) – 要加载的样本的索引

Returns

(waveform, sample_rate, label)

Return type

(Tensor, 整数, 字符串)

LibriMix

class torchaudio.datasets.LibriMix(root: Union[str, pathlib.Path], subset: str = 'train-360', num_speakers: int = 2, sample_rate: int = 8000, task: str = 'sep_clean')[source]

创建 LibriMix [5] 数据集。

Parameters
  • root (strPath) – 存储目录 Libri2MixLibri3Mix 的目录路径。

  • subset (str, optional) – 要使用的子集。选项:[train-360, train-100, dev, 和 test](默认:train-360)。

  • num_speakers (int, optional) – 说话人的数量,用于确定要遍历的目录。数据集将遍历 s1sN 个目录以收集 N 个源音频。(默认值:2)

  • sample_rate (int, optional) – 音频文件的采样率。sample_rate 决定了从哪个子目录获取音频。如果任何音频的采样率不同,则抛出 ValueError。选项:[8000, 16000](默认值:8000)

  • task (str, optional) – LibriMix 的任务。 选项:[enh_single, enh_both, sep_clean, sep_noisy] (默认值:sep_clean

注意

LibriMix 数据集需要手动生成。请查看 https://github.com/JorisCos/LibriMix

__getitem__(key: int)Tuple[int, torch.Tensor, List[torch.Tensor]][source]

从数据集中加载第 n 个样本。 :param key: 要加载的样本的索引 :type key: int

Returns

(sample_rate, mix_waveform, list_of_source_waveforms)

Return type

(整数, 张量, 张量列表)

LIBRISPEECH

class torchaudio.datasets.LIBRISPEECH(root: Union[str, pathlib.Path], url: str = 'train-clean-100', folder_in_archive: str = 'LibriSpeech', download: bool = False)[source]

LibriSpeech 创建数据集 [6]。

Parameters
  • root (strPath) – 数据集所在或下载的目录路径。

  • url (str, optional) – 用于下载数据集的 URL, 或要下载的数据集类型。 允许的类型值为 "dev-clean""dev-other""test-clean""test-other""train-clean-100""train-clean-360""train-other-500"。(默认值:"train-clean-100"

  • folder_in_archive (str, optional) – 数据集的顶层目录。(默认值:"LibriSpeech"

  • download (bool, optional) – 如果在根路径下未找到数据集,是否下载该数据集。(默认值:False)。

__getitem__(n: int)Tuple[torch.Tensor, int, str, int, int, int][source]

从数据集中加载第 n 个样本。

Parameters

n (int) – 要加载的样本的索引

Returns

(waveform, sample_rate, transcript, speaker_id, chapter_id, utterance_id)

Return type

(Tensor, 整数, 字符串, 整数, 整数, 整数)

LibriLightLimited

class torchaudio.datasets.LibriLightLimited(root: Union[str, pathlib.Path], subset: str = '10min', download: bool = False)[source]
Create a Dataset for LibriLightLimited, which is the supervised subset of

LibriLight 数据集。

Parameters
  • root (strPath) – 数据集所在或下载的目录路径。

  • subset (str, optional) – 要使用的子集。选项:[10min, 1h, 10h] (默认值:10min)。

  • download (bool, optional) – 如果在根路径下未找到数据集,是否下载该数据集。(默认值:False)。

__getitem__(n: int)Tuple[torch.Tensor, int, str, int, int, int][source]

从数据集中加载第 n 个样本。 :param n: 要加载的样本索引 :type n: int

Returns

(waveform, sample_rate, transcript, speaker_id, chapter_id, utterance_id)

Return type

(Tensor, 整数, 字符串, 整数, 整数, 整数)

LIBRITTS

class torchaudio.datasets.LIBRITTS(root: Union[str, pathlib.Path], url: str = 'train-clean-100', folder_in_archive: str = 'LibriTTS', download: bool = False)[source]

LibriTTS 创建数据集 [7]。

Parameters
  • root (strPath) – 数据集所在或下载的目录路径。

  • url (str, optional) – 用于下载数据集的 URL, 或要下载的数据集类型。 允许的类型值为 "dev-clean""dev-other""test-clean""test-other""train-clean-100""train-clean-360""train-other-500"。(默认值:"train-clean-100"

  • folder_in_archive (str, optional) – 数据集的顶层目录。(默认值:"LibriTTS"

  • download (bool, optional) – 如果在根路径下未找到数据集,是否下载该数据集。(默认值:False)。

__getitem__(n: int)Tuple[torch.Tensor, int, str, str, int, int, str][source]

从数据集中加载第 n 个样本。

Parameters

n (int) – 要加载的样本的索引

Returns

(waveform, sample_rate, original_text, normalized_text, speaker_id, chapter_id, utterance_id)

Return type

(张量, 整数, 字符串, 字符串, 字符串, 整数, 整数, 字符串)

LJSPEECH

class torchaudio.datasets.LJSPEECH(root: Union[str, pathlib.Path], url: str = 'https://data.keithito.com/data/speech/LJSpeech-1.1.tar.bz2', folder_in_archive: str = 'wavs', download: bool = False)[source]

LJSpeech-1.1 创建数据集 [8]。

Parameters
  • root (strPath) – 数据集所在或下载的目录路径。

  • url (str, optional) – 下载数据集的 URL。 (默认值: "https://data.keithito.com/data/speech/LJSpeech-1.1.tar.bz2")

  • folder_in_archive (str, optional) – 数据集的顶层目录。(默认值:"wavs"

  • download (bool, optional) – 如果在根路径下未找到数据集,是否下载该数据集。(默认值:False)。

__getitem__(n: int)Tuple[torch.Tensor, int, str, str][source]

从数据集中加载第 n 个样本。

Parameters

n (int) – 要加载的样本的索引

Returns

(waveform, sample_rate, transcript, normalized_transcript)

Return type

(张量, 整数, 字符串, 字符串)

SPEECHCOMMANDS

class torchaudio.datasets.SPEECHCOMMANDS(root: Union[str, pathlib.Path], url: str = 'speech_commands_v0.02', folder_in_archive: str = 'SpeechCommands', download: bool = False, subset: Optional[str] = None)[source]

Speech Commands 创建数据集 [9]。

Parameters
  • root (strPath) – 数据集所在或下载的目录路径。

  • url (str, optional) – 用于下载数据集的 URL,或要下载的数据集类型。允许的 type 值为 "speech_commands_v0.01""speech_commands_v0.02"(默认值:"speech_commands_v0.02"

  • folder_in_archive (str, optional) – 数据集的顶层目录。(默认值:"SpeechCommands"

  • download (bool, optional) – 如果在根路径下未找到数据集,是否下载该数据集。(默认值:False)。

  • subset (strNone, 可选) – 选择数据集的子集 [None, “training”, “validation”, “testing”]。None 表示整个数据集。“validation”和“testing”分别在“validation_list.txt”和"testing_list.txt”中定义,而“training”则是其余部分。关于文件“validation_list.txt”和"testing_list.txt”的详细信息在数据集的 README 以及原始论文第 7 节的介绍及其参考文献 12 中有说明。原始论文可在 此处 找到。(默认值:None

__getitem__(n: int)Tuple[torch.Tensor, int, str, str, int][source]

从数据集中加载第 n 个样本。

Parameters

n (int) – 要加载的样本的索引

Returns

(waveform, sample_rate, label, speaker_id, utterance_number)

Return type

(张量, 整数, 字符串, 字符串, 整数)

TEDLIUM

class torchaudio.datasets.TEDLIUM(root: Union[str, pathlib.Path], release: str = 'release1', subset: str = 'train', download: bool = False, audio_ext: str = '.sph')[source]

Tedlium 创建数据集 [10]。它支持第 1、2 和 3 版。

Parameters
  • root (strPath) – 数据集所在或下载的目录路径。

  • release (str, optional) – 发布版本。 允许的值是 "release1""release2""release3"。 (默认值:"release1")。

  • subset (str, optional) – 要使用的数据集子集。有效选项为 "train""dev""test"。默认为 "train"

  • download (bool, optional) – 如果在根路径下未找到数据集,是否下载该数据集。(默认值:False)。

  • audio_ext (str, optional) – 音频文件的扩展名(默认值:".sph"

__getitem__(n: int)Tuple[torch.Tensor, int, str, int, int, int][source]

从数据集中加载第 n 个样本。

Parameters

n (int) – 要加载的样本的索引

Returns

(waveform, sample_rate, transcript, talk_id, speaker_id, identifier)

Return type

元组

property phoneme_dict

音素。从单词到音素元组的映射。 请注意,某些单词的音素为空。

Type

字典[字符串, 元组[字符串]]

VCTK_092

class torchaudio.datasets.VCTK_092(root: str, mic_id: str = 'mic2', download: bool = False, url: str = 'https://datashare.is.ed.ac.uk/bitstream/handle/10283/3443/VCTK-Corpus-0.92.zip', audio_ext='.flac')[source]

创建 VCTK 0.92 [11] 数据集

Parameters
  • root (str) – 找到数据集顶级目录的根目录。

  • mic_id (str, optional) – 麦克风 ID。可以是 "mic1""mic2"。(默认值:"mic2"

  • download (bool, optional) – 如果在根路径下未找到数据集,是否下载该数据集。(默认值:False)。

  • url (str, optional) – 下载数据集的 URL。 (默认值: "https://datashare.is.ed.ac.uk/bitstream/handle/10283/3443/VCTK-Corpus-0.92.zip")

  • audio_ext (str, optional) – 如果数据集转换为非默认音频格式,则使用自定义音频扩展。

注意

  • 由于缺少相应的文本文件,将跳过演讲者 p315 的所有演讲。

  • 由于缺少音频文件,p280的所有演讲将被跳过 mic_id="mic2"

  • 由于缺少音频文件,说话人 p362 的部分演讲将被跳过。

  • 另请参阅:https://datashare.is.ed.ac.uk/handle/10283/3443

__getitem__(n: int)Tuple[torch.Tensor, int, str, str, str][source]

从数据集中加载第 n 个样本。

Parameters

n (int) – 要加载的样本的索引

Returns

(waveform, sample_rate, transcript, speaker_id, utterance_id)

Return type

(张量, 整数, 字符串, 字符串, 字符串)

DR_VCTK

class torchaudio.datasets.DR_VCTK(root: Union[str, pathlib.Path], subset: str = 'train', *, download: bool = False, url: str = 'https://datashare.ed.ac.uk/bitstream/handle/10283/3038/DR-VCTK.zip')[source]

设备录制 VCTK(小数据集版本) 创建数据集 [12]。

Parameters
  • root (strPath) – 数据集顶层目录所在的根目录。

  • subset (str) – 要使用的子集。可以是 "train""test" 之一。(默认值:"train")。

  • 下载 (bool) – 是否在根路径未找到数据集时下载数据集。 (默认: False)。

  • url (str) – 要从中下载数据集的 URL。 (默认值:"https://datashare.ed.ac.uk/bitstream/handle/10283/3038/DR-VCTK.zip")

__getitem__(n: int)Tuple[torch.Tensor, int, torch.Tensor, int, str, str, str, int][source]

从数据集中加载第 n 个样本。

Parameters

n (int) – 要加载的样本的索引

Returns

(waveform_clean, sample_rate_clean, waveform_noisy, sample_rate_noisy, speaker_id,                utterance_id, source, channel_id)

Return type

(张量, 整数, 张量, 整数, 字符串, 字符串, 字符串, 整数)

YESNO

class torchaudio.datasets.YESNO(root: Union[str, pathlib.Path], url: str = 'http://www.openslr.org/resources/1/waves_yesno.tar.gz', folder_in_archive: str = 'waves_yesno', download: bool = False)[source]

YesNo 创建数据集 [13]。

Parameters
  • root (strPath) – 数据集所在或下载的目录路径。

  • url (str, optional) – 下载数据集的 URL。 (默认值: "http://www.openslr.org/resources/1/waves_yesno.tar.gz")

  • folder_in_archive (str, optional) – 数据集的顶层目录。(默认值:"waves_yesno"

  • download (bool, optional) – 如果在根路径下未找到数据集,是否下载该数据集。(默认值:False)。

Tutorials using YESNO:
__getitem__(n: int)Tuple[torch.Tensor, int, List[int]][source]

从数据集中加载第 n 个样本。

Parameters

n (int) – 要加载的样本的索引

Returns

(waveform, sample_rate, labels)

Return type

(Tensor, 整数, List[整数])

QUESST14

class torchaudio.datasets.QUESST14(root: Union[str, pathlib.Path], subset: str, language: Optional[str] = 'nnenglish', download: bool = False)[source]

创建 QUESST14 [14] 数据集

Parameters
  • root (strPath) – 数据集顶层目录所在的根目录

  • subset (str) – 要使用的数据集子集。选项:["docs", "dev", "eval"]。

  • language (strNone, 可选) – 要获取数据集的语言。 选项:[None, albanian, basque, czech, nnenglish, romanian, slovak]。 如果为 None,则数据集包含所有语言。(默认值:"nnenglish"

  • download (bool, optional) – 如果在根路径下未找到数据集,是否下载该数据集。 (默认值: False)

__getitem__(n: int)Tuple[torch.Tensor, int, str][source]

从数据集中加载第 n 个样本。

Parameters

n (int) – 要加载的样本的索引

Returns

(waveform, sample_rate, file_name)

Return type

(Tensor, 整数, 字符串)

参考文献

1

John Kominek, Alan W Black, 和 Ver Ver. CMU Arctic 数据库用于语音合成。技术报告,2003年。

2

R.L. Weide. 卡内基梅隆发音词典. 1998. URL: http://www.speech.cs.cmu.edu/cgi-bin/cmudict.

3

Rosana Ardila, Megan Branson, Kelly Davis, Michael Henretty, Michael Kohler, Josh Meyer, Reuben Morais, Lindsay Saunders, Francis M. Tyers, 和 Gregor Weber。Common voice: 一个大规模多语言语音语料库。2020。 arXiv:1912.06670.

4

George Tzanetakis, Georg Essl, 和 Perry Cook。音频信号的自动音乐流派分类。2001年。网址:http://ismir2001.ismir.net/pdf/tzanetakis.pdf

5

Joris Cosentino, Manuel Pariente, Samuele Cornell, Antoine Deleforge, 和 Emmanuel Vincent. Librimix: 一个用于可推广语音分离的开源数据集。2020. arXiv:2005.11262.

6

Vassil Panayotov, Guoguo Chen, Daniel Povey, 和 Sanjeev Khudanpur。Librispeech:一个基于公共领域有声书的语音识别语料库。在 2015 IEEE 国际声学、语音与信号处理会议(ICASSP),卷,5206–5210。2015。 doi:10.1109/ICASSP.2015.7178964.

7

Heiga Zen, Viet-Trung Dang, Robert A. J. Clark, Yu Zhang, Ron J. Weiss, Ye Jia, Z. Chen, and Yonghui Wu. Libritts: 一个源自LibriSpeech的文本到语音语料库。 ArXiv, 2019.

8

Keith Ito 和 Linda Johnson。The lj speech dataset。https://keithito.com/LJ-Speech-Dataset/,2017。

9

P. Warden. 语音指令:一个有限词汇量语音识别数据集。 ArXiv e-prints, 2018年4月。URL: https://arxiv.org/abs/1804.03209, arXiv:1804.03209.

10

Anthony Rousseau, Paul Deléglise, 和 Yannick Estève. Ted-lium: 一个专用的自动语音识别语料库。在 语言资源与评估会议(LREC) 中,125–129。2012年。

11

Junichi Yamagishi, Christophe Veaux, 和 Kirsten MacDonald。CSTR VCTK语料库:用于CSTR语音克隆工具包的英语多说话人语料库(版本0.92)。2019年。 doi:10.7488/ds/2645.

12

Seyyed Saeed Sarfjoo 和 Junichi Yamagishi. Device recorded vctk(小规模子集版本)。2018.

13

Yesno. URL: http://www.openslr.org/1/.

14

Xavier Anguera Miro, Luis Javier Rodriguez-Fuentes, Andi Buzo, Florian Metze, Igor Szoke, 和 Mikel Peñagarikano. Quesst2014: 在真实查询中评估零资源设置下的示例查询语音搜索。 2015 IEEE 国际声学、语音与信号处理会议(ICASSP), 第 5833–5837 页, 2015.

文档

访问 PyTorch 的全面开发人员文档

查看文档

教程

获取面向初学者和高级开发人员的深入教程

查看教程

资源

查找开发资源并解答您的问题

查看资源