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 1
1
This 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 31
31
32
32
33
33
class Tacotron2Loss (nn .Module ):
34
- """Tacotron2 loss function adapted from:
34
+ """Tacotron2 loss function modified from:
35
35
https://github.com/NVIDIA/DeepLearningExamples/blob/master/PyTorch/SpeechSynthesis/Tacotron2/tacotron2/loss_function.py
36
36
"""
37
37
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
import torch
2
- import unittest
3
2
4
3
from .tacotron2_loss_impl import (
5
4
Tacotron2LossShapeTests ,
6
5
Tacotron2LossTorchscriptTests ,
7
6
Tacotron2LossGradcheckTests ,
8
7
)
8
+ from torchaudio_unittest .common_utils import PytorchTestCase
9
9
10
10
11
- class TestTacotron2LossShapeFloat32CPU (unittest . TestCase , Tacotron2LossShapeTests ):
11
+ class TestTacotron2LossShapeFloat32CPU (PytorchTestCase , Tacotron2LossShapeTests ):
12
12
dtype = torch .float32
13
13
device = torch .device ("cpu" )
14
14
15
15
16
- class TestTacotron2TorchsciptFloat32CPU (unittest . TestCase , Tacotron2LossTorchscriptTests ):
16
+ class TestTacotron2TorchsciptFloat32CPU (PytorchTestCase , Tacotron2LossTorchscriptTests ):
17
17
dtype = torch .float32
18
18
device = torch .device ("cpu" )
19
19
20
20
21
- class TestTacotron2GradcheckFloat64CPU (unittest . TestCase , Tacotron2LossGradcheckTests ):
21
+ class TestTacotron2GradcheckFloat64CPU (PytorchTestCase , Tacotron2LossGradcheckTests ):
22
22
dtype = torch .float64 # gradcheck needs a higher numerical accuracy
23
23
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
-
5
1
import torch
6
2
from torch .autograd import gradcheck , gradgradcheck
7
3
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
39
6
40
7
41
8
class Tacotron2LossInputMixin (TempDirMixin ):
You can’t perform that action at this time.
0 commit comments