-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SynthesisEngineの抽象基底クラスSynthesisEngineBaseを追加 (#227)
* add SynthesisEngineBase * use NotImplementedError * add abstractmethod annotation * add metaclass=ABCMeta * add test_mock_synthesis_engine * split test * synthesis test
- Loading branch information
Showing
9 changed files
with
293 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
from unittest import TestCase | ||
|
||
from voicevox_engine.dev.synthesis_engine import MockSynthesisEngine | ||
from voicevox_engine.kana_parser import create_kana | ||
from voicevox_engine.model import AccentPhrase, AudioQuery, Mora | ||
|
||
|
||
class TestMockSynthesisEngine(TestCase): | ||
def setUp(self): | ||
super().setUp() | ||
|
||
self.accent_phrases_hello_hiho = [ | ||
AccentPhrase( | ||
moras=[ | ||
Mora( | ||
text="コ", | ||
consonant="k", | ||
consonant_length=0.0, | ||
vowel="o", | ||
vowel_length=0.0, | ||
pitch=0.0, | ||
), | ||
Mora( | ||
text="ン", | ||
consonant=None, | ||
consonant_length=None, | ||
vowel="N", | ||
vowel_length=0.0, | ||
pitch=0.0, | ||
), | ||
Mora( | ||
text="ニ", | ||
consonant="n", | ||
consonant_length=0.0, | ||
vowel="i", | ||
vowel_length=0.0, | ||
pitch=0.0, | ||
), | ||
Mora( | ||
text="チ", | ||
consonant="ch", | ||
consonant_length=0.0, | ||
vowel="i", | ||
vowel_length=0.0, | ||
pitch=0.0, | ||
), | ||
Mora( | ||
text="ワ", | ||
consonant="w", | ||
consonant_length=0.0, | ||
vowel="a", | ||
vowel_length=0.0, | ||
pitch=0.0, | ||
), | ||
], | ||
accent=5, | ||
pause_mora=Mora( | ||
text="、", | ||
consonant=None, | ||
consonant_length=None, | ||
vowel="pau", | ||
vowel_length=0.0, | ||
pitch=0.0, | ||
), | ||
), | ||
AccentPhrase( | ||
moras=[ | ||
Mora( | ||
text="ヒ", | ||
consonant="h", | ||
consonant_length=0.0, | ||
vowel="i", | ||
vowel_length=0.0, | ||
pitch=0.0, | ||
), | ||
Mora( | ||
text="ホ", | ||
consonant="h", | ||
consonant_length=0.0, | ||
vowel="o", | ||
vowel_length=0.0, | ||
pitch=0.0, | ||
), | ||
Mora( | ||
text="デ", | ||
consonant="d", | ||
consonant_length=0.0, | ||
vowel="e", | ||
vowel_length=0.0, | ||
pitch=0.0, | ||
), | ||
Mora( | ||
text="ス", | ||
consonant="s", | ||
consonant_length=0.0, | ||
vowel="U", | ||
vowel_length=0.0, | ||
pitch=0.0, | ||
), | ||
], | ||
accent=1, | ||
pause_mora=None, | ||
), | ||
] | ||
self.engine = MockSynthesisEngine(speakers="") | ||
|
||
def test_replace_phoneme_length(self): | ||
self.assertEqual( | ||
self.engine.replace_phoneme_length( | ||
accent_phrases=self.accent_phrases_hello_hiho, | ||
speaker_id=0, | ||
), | ||
self.accent_phrases_hello_hiho, | ||
) | ||
|
||
def test_replace_mora_pitch(self): | ||
self.assertEqual( | ||
self.engine.replace_mora_pitch( | ||
accent_phrases=self.accent_phrases_hello_hiho, | ||
speaker_id=0, | ||
), | ||
self.accent_phrases_hello_hiho, | ||
) | ||
|
||
def test_synthesis(self): | ||
self.engine.synthesis( | ||
AudioQuery( | ||
accent_phrases=self.accent_phrases_hello_hiho, | ||
speedScale=1, | ||
pitchScale=0, | ||
intonationScale=1, | ||
volumeScale=1, | ||
prePhonemeLength=0.1, | ||
postPhonemeLength=0.1, | ||
outputSamplingRate=24000, | ||
outputStereo=False, | ||
kana=create_kana(self.accent_phrases_hello_hiho), | ||
), | ||
speaker_id=0, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .mock import SynthesisEngine | ||
from .mock import MockSynthesisEngine | ||
|
||
__all__ = ["SynthesisEngine"] | ||
__all__ = ["MockSynthesisEngine"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
from .forwarder import Forwarder | ||
from .make_synthesis_engine import make_synthesis_engine | ||
from .synthesis_engine import SynthesisEngine | ||
from .synthesis_engine_base import SynthesisEngineBase | ||
|
||
__all__ = [ | ||
"Forwarder", | ||
"make_synthesis_engine", | ||
"SynthesisEngine", | ||
"SynthesisEngineBase", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.