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-31 12:13:55 +01:00
|
|
|
os.system('rm mini_chapter_*.wav')
|
2025-01-31 14:13:37 +01:00
|
|
|
merged_args = dict(voice='af_sky', pick_manually=False, speed=1.0)
|
|
|
|
merged_args.update(kwargs)
|
|
|
|
main(file_path, **merged_args)
|
2025-01-29 11:02:50 +01:00
|
|
|
|
2025-01-31 12:13:55 +01:00
|
|
|
def test_1_allan_poe(self):
|
2025-01-23 22:31:22 +01:00
|
|
|
Path('poe.m4b').unlink(missing_ok=True)
|
2025-01-31 12:13:55 +01:00
|
|
|
os.system('rm poe_chapter_*.wav')
|
2025-01-23 22:31:22 +01:00
|
|
|
self.base(file_path='../epub/poe.epub')
|
|
|
|
self.assertTrue(Path('poe.m4b').exists())
|
|
|
|
|
2025-01-31 12:13:55 +01:00
|
|
|
def test_2_mini(self):
|
|
|
|
Path('mini.m4b').unlink(missing_ok=True)
|
|
|
|
os.system('rm mini_chapter_*.wav')
|
|
|
|
self.base(file_path='../epub/mini.epub')
|
|
|
|
self.assertTrue(Path('mini.m4b').exists())
|
|
|
|
|
|
|
|
def test_3_orwell(self):
|
2025-01-30 09:24:21 +01:00
|
|
|
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')
|
2025-01-31 14:13:37 +01:00
|
|
|
|
2025-01-31 14:39:32 +01:00
|
|
|
def test_0_pirandello(self):
|
|
|
|
Path('pirandello.m4b').unlink(missing_ok=True)
|
|
|
|
os.system('rm pirandello_chapter_*.wav')
|
|
|
|
self.base(file_path='../epub/pirandello.epub', voice='im_nicola')
|
|
|
|
self.assertTrue(Path('pirandello.m4b').exists())
|
|
|
|
|
2025-01-31 14:13:37 +01:00
|
|
|
def test_0_manzoni(self):
|
|
|
|
Path('manzoni.m4b').unlink(missing_ok=True)
|
|
|
|
os.system('rm manzoni_chapter_*.wav')
|
|
|
|
self.base(file_path='../epub/manzoni.epub', voice='im_nicola')
|
|
|
|
self.assertTrue(Path('manzoni.m4b').exists())
|