Skip to content

Commit

Permalink
削除: Utterance.phonemes 内コンテキスト更新 (VOICEVOX#905)
Browse files Browse the repository at this point in the history
* Remove: `Utterance.phonemes` 内コンテキスト更新

* Remove: Utterance.phonemes 内コンテキスト更新テスト
  • Loading branch information
tarepan authored Dec 22, 2023
1 parent 6e239fe commit 68a439d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 131 deletions.
69 changes: 0 additions & 69 deletions test/test_full_context_label.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from copy import deepcopy
from itertools import chain
from unittest import TestCase

from voicevox_engine.tts_pipeline.full_context_label import (
Expand Down Expand Up @@ -341,73 +340,5 @@ def test_phonemes(self):
expects_hello_hiho = "sil k o N n i ch i w a pau h i h o d e s U sil"
self.assertEqual(outputs_hello_hiho, expects_hello_hiho)

changed_utterance = Utterance.from_labels(self.utterance_hello_hiho.phonemes)
self.assertEqual(len(changed_utterance.breath_groups), 2)
accent_phrases = list(
chain.from_iterable(
breath_group.accent_phrases
for breath_group in changed_utterance.breath_groups
)
)
for prev, cent, post in zip(
[None] + accent_phrases[:-1],
accent_phrases,
accent_phrases[1:] + [None],
):
mora_num = len(cent.moras)
accent = cent.accent

if prev is not None:
for phoneme in prev.phonemes:
self.assertEqual(phoneme.contexts["g1"], str(mora_num))
self.assertEqual(phoneme.contexts["g2"], str(accent))

if post is not None:
for phoneme in post.phonemes:
self.assertEqual(phoneme.contexts["e1"], str(mora_num))
self.assertEqual(phoneme.contexts["e2"], str(accent))

for phoneme in cent.phonemes:
self.assertEqual(
phoneme.contexts["k2"],
str(
sum(
[
len(breath_group.accent_phrases)
for breath_group in changed_utterance.breath_groups
]
)
),
)

for prev, cent, post in zip(
[None] + changed_utterance.breath_groups[:-1],
changed_utterance.breath_groups,
changed_utterance.breath_groups[1:] + [None],
):
accent_phrase_num = len(cent.accent_phrases)

if prev is not None:
for phoneme in prev.phonemes:
self.assertEqual(phoneme.contexts["j1"], str(accent_phrase_num))

if post is not None:
for phoneme in post.phonemes:
self.assertEqual(phoneme.contexts["h1"], str(accent_phrase_num))

for phoneme in cent.phonemes:
self.assertEqual(phoneme.contexts["i1"], str(accent_phrase_num))
self.assertEqual(
phoneme.contexts["i5"],
str(accent_phrases.index(cent.accent_phrases[0]) + 1),
)
self.assertEqual(
phoneme.contexts["i6"],
str(
len(accent_phrases)
- accent_phrases.index(cent.accent_phrases[0])
),
)

def test_labels(self):
self.assertEqual(features(self.utterance_hello_hiho), self.test_case_hello_hiho)
62 changes: 0 additions & 62 deletions voicevox_engine/tts_pipeline/full_context_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,68 +339,6 @@ def phonemes(self):
labels : list[Label]
Utteranceクラスに直接的・間接的に含まれる、全てのLabelを返す
"""
accent_phrases = list(
chain.from_iterable(
breath_group.accent_phrases for breath_group in self.breath_groups
)
)
for prev, cent, post in zip(
[None] + accent_phrases[:-1],
accent_phrases,
accent_phrases[1:] + [None],
):
mora_num = len(cent.moras)
accent = cent.accent

if prev is not None:
prev.set_context("g1", str(mora_num))
prev.set_context("g2", str(accent))

if post is not None:
post.set_context("e1", str(mora_num))
post.set_context("e2", str(accent))

cent.set_context("f1", str(mora_num))
cent.set_context("f2", str(accent))
for i_mora, mora in enumerate(cent.moras):
mora.set_context("a1", str(i_mora - accent + 1))
mora.set_context("a2", str(i_mora + 1))
mora.set_context("a3", str(mora_num - i_mora))

for prev, cent, post in zip(
[None] + self.breath_groups[:-1],
self.breath_groups,
self.breath_groups[1:] + [None],
):
accent_phrase_num = len(cent.accent_phrases)

if prev is not None:
prev.set_context("j1", str(accent_phrase_num))

if post is not None:
post.set_context("h1", str(accent_phrase_num))

cent.set_context("i1", str(accent_phrase_num))
cent.set_context(
"i5", str(accent_phrases.index(cent.accent_phrases[0]) + 1)
)
cent.set_context(
"i6",
str(len(accent_phrases) - accent_phrases.index(cent.accent_phrases[0])),
)

self.set_context(
"k2",
str(
sum(
[
len(breath_group.accent_phrases)
for breath_group in self.breath_groups
]
)
),
)

labels: list[Label] = []
for i in range(len(self.pauses)):
if self.pauses[i] is not None:
Expand Down

0 comments on commit 68a439d

Please sign in to comment.