2025-01-30 16:04:58 +01:00
|
|
|
import os
|
2025-01-23 22:31:22 +01:00
|
|
|
import unittest
|
|
|
|
from pathlib import Path
|
|
|
|
|
2025-01-29 11:02:50 +01:00
|
|
|
from kokoro import KPipeline
|
|
|
|
|
|
|
|
from audiblez import main
|
2025-01-23 22:31:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
class MainTest(unittest.TestCase):
|
2025-01-29 11:02:50 +01:00
|
|
|
def base(self, file_path, **kwargs):
|
2025-01-30 09:24:21 +01:00
|
|
|
pipeline = KPipeline(lang_code='a')
|
2025-01-29 11:02:50 +01:00
|
|
|
main(pipeline, file_path=file_path, voice='af_sky', pick_manually=False, speed=1, **kwargs)
|
|
|
|
|
2025-01-23 22:31:22 +01:00
|
|
|
def test_1_mini(self):
|
|
|
|
Path('mini.m4b').unlink(missing_ok=True)
|
|
|
|
self.base(file_path='../epub/mini.epub')
|
|
|
|
self.assertTrue(Path('mini.m4b').exists())
|
|
|
|
|
|
|
|
def test_2_allan_poe(self):
|
|
|
|
Path('poe.m4b').unlink(missing_ok=True)
|
|
|
|
self.base(file_path='../epub/poe.epub')
|
|
|
|
self.assertTrue(Path('poe.m4b').exists())
|
|
|
|
|
2025-01-30 09:24:21 +01:00
|
|
|
def test_orwell(self):
|
|
|
|
Path('orwell.m4b').unlink(missing_ok=True)
|
2025-01-30 16:04:58 +01:00
|
|
|
os.system('rm orwell_chapter_*.wav')
|
2025-01-30 09:24:21 +01:00
|
|
|
self.base(file_path='../epub/orwell.epub')
|
|
|
|
self.assertTrue(Path('orwell.m4b').exists())
|
2025-01-30 16:04:58 +01:00
|
|
|
for i in range(8):
|
|
|
|
self.assertTrue(Path(f'orwell_chapter_{i}.wav').exists())
|
|
|
|
self.assertTrue(Path(f'orwell_chapter_{i}.wav').stat().st_size > 300 * 1024, 'file should be larger than 300KB, surely failed')
|