Compress hallucinated XTTS silence

This commit is contained in:
Mikei386
2026-09-03 23:46:32 +02:00
parent 435c59da41
commit 5afdf46a7c
3 changed files with 49 additions and 1 deletions
@@ -184,6 +184,19 @@ class AudioJoinTests(unittest.TestCase):
sentence = gateway._join_pcm([("Fertig.", spoken), ("Weiter", spoken)])
self.assertGreater(len(sentence), len(inline))
def test_long_internal_silence_is_shortened(self):
spoken = self.pcm([900] * 1000)
long_silence = self.pcm([0] * int(24000 * 1.5))
result = gateway._compress_internal_silence(spoken + long_silence + spoken)
expected_keep = int(24000 * gateway.INTERNAL_SILENCE_KEEP_MS / 1000) * 2
self.assertEqual(len(result), len(spoken) * 2 + expected_keep)
def test_natural_short_pause_is_preserved(self):
spoken = self.pcm([900] * 1000)
short_silence = self.pcm([0] * int(24000 * 0.3))
original = spoken + short_silence + spoken
self.assertEqual(gateway._compress_internal_silence(original), original)
if __name__ == "__main__":
unittest.main()