Skip to content

Commit cc9f515

Browse files
authored
Fix CMUARCTIC text transcripts reader. (#4164)
1 parent ad99271 commit cc9f515

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/torchaudio/datasets/cmuarctic.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import csv
21
import os
32
from pathlib import Path
43
from typing import Tuple, Union
@@ -128,9 +127,8 @@ def __init__(
128127
)
129128
self._text = os.path.join(self._path, self._folder_text, self._file_text)
130129

131-
with open(self._text, "r") as text:
132-
walker = csv.reader(text)
133-
self._walker = list(walker)
130+
with open(self._text, "r", newline=None) as text:
131+
self._walker = [[line.rstrip("\n")] for line in text.readlines()]
134132

135133
def __getitem__(self, n: int) -> Tuple[Tensor, int, str, str]:
136134
"""Load the n-th sample from the dataset.

test/torchaudio_unittest/datasets/cmuarctic_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def get_mock_dataset(root_dir):
1111
"""
1212
mocked_data = []
1313
sample_rate = 16000
14-
transcript = "This is a test transcript."
14+
transcript = "This is a test transcript, with comma."
1515

1616
base_dir = os.path.join(root_dir, "ARCTIC", "cmu_us_aew_arctic")
1717
txt_dir = os.path.join(base_dir, "etc")

0 commit comments

Comments
 (0)