mirror of
https://github.com/santinic/audiblez.git
synced 2025-04-13 09:38:57 +00:00
44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
import os
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from audiblez.core import main
|
|
|
|
|
|
class MainTest(unittest.TestCase):
|
|
def base(self, name, url, **kwargs):
|
|
if not Path(f'{name}.epub').exists():
|
|
os.system(f'wget {url} -O {name}.epub')
|
|
Path(f'{name}.m4b').unlink(missing_ok=True)
|
|
os.system(f'rm {name}_chapter_*.wav')
|
|
merged_args = dict(voice='af_sky', pick_manually=False, speed=1.0, max_chapters=1, max_sentences=2)
|
|
merged_args.update(kwargs)
|
|
main(f'{name}.epub', **merged_args)
|
|
m4b_file = Path(f'{name}.m4b')
|
|
self.assertTrue(m4b_file.exists())
|
|
self.assertTrue(m4b_file.stat().st_size > 1024)
|
|
|
|
def test_poe(self):
|
|
url = 'https://www.gutenberg.org/ebooks/1064.epub.images'
|
|
self.base('poe', url)
|
|
|
|
def test_orwell(self):
|
|
url = 'https://archive.org/download/AnimalFarmByGeorgeOrwell/Animal%20Farm%20by%20George%20Orwell.epub'
|
|
self.base('orwell', url)
|
|
|
|
def test_italian_pirandello(self):
|
|
url = 'https://www.liberliber.eu/mediateca/libri/p/pirandello/cosi_e_se_vi_pare_1925/epub/pirandello_cosi_e_se_vi_pare_1925.epub'
|
|
self.base('pirandello', url, voice='im_nicola')
|
|
self.assertTrue(Path('pirandello.m4b').exists())
|
|
|
|
def test_italian_manzoni(self):
|
|
url = 'https://www.liberliber.eu/mediateca/libri/m/manzoni/i_promessi_sposi/epub/manzoni_i_promessi_sposi.epub'
|
|
self.base('manzoni', url, voice='im_nicola')
|
|
|
|
def test_french_baudelaire(self):
|
|
url = 'http://gallica.bnf.fr/ark:/12148/bpt6k70861t.epub'
|
|
self.base('baudelaire', url, voice='ff_siwis')
|
|
|
|
def test_chinese(self):
|
|
url = 'https://www.gutenberg.org/ebooks/24225.epub3.images'
|
|
self.base('chinese', url, voice='zf_xiaobei')
|