mirror of
https://github.com/santinic/audiblez.git
synced 2025-08-31 22:09:26 +00:00
fix
This commit is contained in:
parent
058847c722
commit
4d2380bf7d
3 changed files with 7 additions and 3 deletions
|
@ -185,7 +185,6 @@ def gen_text(text, voice='af_heart', output_file='text.wav', speed=1, play=False
|
||||||
subprocess.run(['ffplay', '-autoexit', '-nodisp', output_file])
|
subprocess.run(['ffplay', '-autoexit', '-nodisp', output_file])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def find_document_chapters_and_extract_texts(book):
|
def find_document_chapters_and_extract_texts(book):
|
||||||
"""Returns every chapter that is an ITEM_DOCUMENT and enriches each chapter with extracted_text."""
|
"""Returns every chapter that is an ITEM_DOCUMENT and enriches each chapter with extracted_text."""
|
||||||
document_chapters = []
|
document_chapters = []
|
||||||
|
@ -305,7 +304,7 @@ def probe_duration(file_name):
|
||||||
|
|
||||||
|
|
||||||
def create_index_file(title, creator, chapter_mp3_files, output_folder):
|
def create_index_file(title, creator, chapter_mp3_files, output_folder):
|
||||||
with open(Path(output_folder) / "chapters.txt", "w") as f:
|
with open(Path(output_folder) / "chapters.txt", "w", encoding="utf-8") as f:
|
||||||
f.write(f";FFMETADATA1\ntitle={title}\nartist={creator}\n\n")
|
f.write(f";FFMETADATA1\ntitle={title}\nartist={creator}\n\n")
|
||||||
start = 0
|
start = 0
|
||||||
i = 0
|
i = 0
|
||||||
|
|
|
@ -28,6 +28,7 @@ class CliTest(unittest.TestCase):
|
||||||
self.assertTrue(Path('./prova/mini.m4b').exists())
|
self.assertTrue(Path('./prova/mini.m4b').exists())
|
||||||
self.assertTrue(Path('./prova/mini.m4b').stat().st_size > 256 * 1024)
|
self.assertTrue(Path('./prova/mini.m4b').stat().st_size > 256 * 1024)
|
||||||
|
|
||||||
|
@unittest.skip('Not implemented yet')
|
||||||
def test_md(self):
|
def test_md(self):
|
||||||
content = (
|
content = (
|
||||||
'## Italy\n'
|
'## Italy\n'
|
||||||
|
@ -42,6 +43,7 @@ class CliTest(unittest.TestCase):
|
||||||
self.assertTrue(Path(file_name).exists())
|
self.assertTrue(Path(file_name).exists())
|
||||||
self.assertTrue(Path('file_name').stat().st_size > 256 * 1024)
|
self.assertTrue(Path('file_name').stat().st_size > 256 * 1024)
|
||||||
|
|
||||||
|
@unittest.skip('Not implemented yet')
|
||||||
def test_txt(self):
|
def test_txt(self):
|
||||||
content = (
|
content = (
|
||||||
'Italy, officially the Italian Republic, is a country in Southern and Western Europe. '
|
'Italy, officially the Italian Republic, is a country in Southern and Western Europe. '
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
import unittest
|
import unittest
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
@ -45,8 +46,10 @@ class MainTest(unittest.TestCase):
|
||||||
url = 'https://www.gutenberg.org/ebooks/24225.epub3.images'
|
url = 'https://www.gutenberg.org/ebooks/24225.epub3.images'
|
||||||
self.base('chinese', url, voice='zf_xiaobei')
|
self.base('chinese', url, voice='zf_xiaobei')
|
||||||
|
|
||||||
def test_leigh(self):
|
def test_leigh_and_play_result(self):
|
||||||
book = epub.read_epub('leigh.epub')
|
book = epub.read_epub('leigh.epub')
|
||||||
document_chapters = find_document_chapters_and_extract_texts(book)
|
document_chapters = find_document_chapters_and_extract_texts(book)
|
||||||
chapters = [c for c in document_chapters if c.get_name() == 'Text/Chap07.xhtml']
|
chapters = [c for c in document_chapters if c.get_name() == 'Text/Chap07.xhtml']
|
||||||
self.base('leigh', voice='af_heart', selected_chapters=chapters, max_sentences=5)
|
self.base('leigh', voice='af_heart', selected_chapters=chapters, max_sentences=5)
|
||||||
|
subprocess.run(['ffplay', '-nodisp', '-autoexit', 'leigh.m4b'], check=True)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue