Skip to content

Commit 1f0f7d3

Browse files
authored
Update transformer_asr.py (keras-team#1959)
Issue with windows path, I change the way to manage path to cut file name correctly.
1 parent d2d4da1 commit 1f0f7d3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

examples/audio/transformer_asr.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
- [LJSpeech Dataset](https://keithito.com/LJ-Speech-Dataset/)
3131
"""
3232

33-
33+
import re
3434
import os
3535

3636
os.environ["KERAS_BACKEND"] = "tensorflow"
@@ -289,6 +289,8 @@ def generate(self, source, target_start_token_idx):
289289
takes ~5 minutes for the extraction of files.
290290
"""
291291

292+
pattern_wav_name = re.compile(r'([^/\\\.]+)')
293+
292294
keras.utils.get_file(
293295
os.path.join(os.getcwd(), "data.tar.gz"),
294296
"https://data.keithito.com/data/speech/LJSpeech-1.1.tar.bz2",
@@ -313,7 +315,7 @@ def get_data(wavs, id_to_text, maxlen=50):
313315
"""returns mapping of audio paths and transcription texts"""
314316
data = []
315317
for w in wavs:
316-
id = w.split("/")[-1].split(".")[0]
318+
id = pattern_wav_name.split(test)[-4]
317319
if len(id_to_text[id]) < maxlen:
318320
data.append({"audio": w, "text": id_to_text[id]})
319321
return data

0 commit comments

Comments
 (0)