mirror of
https://github.com/santinic/audiblez.git
synced 2025-08-05 16:48:55 +00:00
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import os
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from kokoro import KPipeline
|
|
|
|
from audiblez import main
|
|
|
|
|
|
class MainTest(unittest.TestCase):
|
|
def base(self, file_path, **kwargs):
|
|
pipeline = KPipeline(lang_code='a')
|
|
main(pipeline, file_path=file_path, voice='af_sky', pick_manually=False, speed=1, **kwargs)
|
|
|
|
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())
|
|
|
|
def test_orwell(self):
|
|
Path('orwell.m4b').unlink(missing_ok=True)
|
|
os.system('rm orwell_chapter_*.wav')
|
|
self.base(file_path='../epub/orwell.epub')
|
|
self.assertTrue(Path('orwell.m4b').exists())
|
|
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')
|