File tree Expand file tree Collapse file tree 8 files changed +33
-99
lines changed
examples/pipeline_tacotron2
test/torchaudio_unittest/example/tacotron2 Expand file tree Collapse file tree 8 files changed +33
-99
lines changed Original file line number Diff line number Diff line change 11This is an example pipeline for text-to-speech using Tacotron2.
2-
3-
4- ## Instructions for running tests
5-
6- #### Install required the package for testing
7-
8- ``` bash
9- pip install pytest
10- ```
11-
12- #### Run tests
13-
14- Execute the following command in the directory ` examples/pipeline_tacotron2/ `
15-
16- ``` bash
17- pytest .
18- ```
Original file line number Diff line number Diff line change 3131
3232
3333class Tacotron2Loss (nn .Module ):
34- """Tacotron2 loss function adapted from:
34+ """Tacotron2 loss function modified from:
3535 https://github.com/NVIDIA/DeepLearningExamples/blob/master/PyTorch/SpeechSynthesis/Tacotron2/tacotron2/loss_function.py
3636 """
3737
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import torch
2- import unittest
32
43from .tacotron2_loss_impl import (
54 Tacotron2LossShapeTests ,
65 Tacotron2LossTorchscriptTests ,
76 Tacotron2LossGradcheckTests ,
87)
8+ from torchaudio_unittest .common_utils import PytorchTestCase
99
1010
11- class TestTacotron2LossShapeFloat32CPU (unittest . TestCase , Tacotron2LossShapeTests ):
11+ class TestTacotron2LossShapeFloat32CPU (PytorchTestCase , Tacotron2LossShapeTests ):
1212 dtype = torch .float32
1313 device = torch .device ("cpu" )
1414
1515
16- class TestTacotron2TorchsciptFloat32CPU (unittest . TestCase , Tacotron2LossTorchscriptTests ):
16+ class TestTacotron2TorchsciptFloat32CPU (PytorchTestCase , Tacotron2LossTorchscriptTests ):
1717 dtype = torch .float32
1818 device = torch .device ("cpu" )
1919
2020
21- class TestTacotron2GradcheckFloat64CPU (unittest . TestCase , Tacotron2LossGradcheckTests ):
21+ class TestTacotron2GradcheckFloat64CPU (PytorchTestCase , Tacotron2LossGradcheckTests ):
2222 dtype = torch .float64 # gradcheck needs a higher numerical accuracy
2323 device = torch .device ("cpu" )
Original file line number Diff line number Diff line change 1+ import torch
2+
3+ from .tacotron2_loss_impl import (
4+ Tacotron2LossShapeTests ,
5+ Tacotron2LossTorchscriptTests ,
6+ Tacotron2LossGradcheckTests ,
7+ )
8+ from torchaudio_unittest .common_utils import skipIfNoCuda , PytorchTestCase
9+
10+
11+ @skipIfNoCuda
12+ class TestTacotron2LossShapeFloat32CUDA (PytorchTestCase , Tacotron2LossShapeTests ):
13+ dtype = torch .float32
14+ device = torch .device ("cuda" )
15+
16+
17+ @skipIfNoCuda
18+ class TestTacotron2TorchsciptFloat32CUDA (PytorchTestCase , Tacotron2LossTorchscriptTests ):
19+ dtype = torch .float32
20+ device = torch .device ("cuda" )
21+
22+
23+ @skipIfNoCuda
24+ class TestTacotron2GradcheckFloat64CUDA (PytorchTestCase , Tacotron2LossGradcheckTests ):
25+ dtype = torch .float64 # gradcheck needs a higher numerical accuracy
26+ device = torch .device ("cuda" )
Original file line number Diff line number Diff line change 1- import os
2- import unittest
3- import tempfile
4-
51import torch
62from torch .autograd import gradcheck , gradgradcheck
73
8- from .loss_function import Tacotron2Loss
9-
10-
11- class TempDirMixin :
12- """Mixin to provide easy access to temp dir"""
13-
14- temp_dir_ = None
15-
16- @classmethod
17- def get_base_temp_dir (cls ):
18- # If TORCHAUDIO_TEST_TEMP_DIR is set, use it instead of temporary directory.
19- # this is handy for debugging.
20- key = "TORCHAUDIO_TEST_TEMP_DIR"
21- if key in os .environ :
22- return os .environ [key ]
23- if cls .temp_dir_ is None :
24- cls .temp_dir_ = tempfile .TemporaryDirectory ()
25- return cls .temp_dir_ .name
26-
27- @classmethod
28- def tearDownClass (cls ):
29- super ().tearDownClass ()
30- if cls .temp_dir_ is not None :
31- cls .temp_dir_ .cleanup ()
32- cls .temp_dir_ = None
33-
34- def get_temp_path (self , * paths ):
35- temp_dir = os .path .join (self .get_base_temp_dir (), self .id ())
36- path = os .path .join (temp_dir , * paths )
37- os .makedirs (os .path .dirname (path ), exist_ok = True )
38- return path
4+ from pipeline_tacotron2 .loss import Tacotron2Loss
5+ from torchaudio_unittest .common_utils import TempDirMixin
396
407
418class Tacotron2LossInputMixin (TempDirMixin ):
You can’t perform that action at this time.
0 commit comments