mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 05:40:26 +02:00
Ensure appropriate speech pauses by adding newlines at epub processing
This commit is contained in:
@@ -915,7 +915,11 @@ class EpubParser(BaseBookParser):
|
|||||||
|
|
||||||
if slice_html.strip():
|
if slice_html.strip():
|
||||||
slice_soup = BeautifulSoup(slice_html, "html.parser")
|
slice_soup = BeautifulSoup(slice_html, "html.parser")
|
||||||
for tag in slice_soup.find_all(["p", "div"]):
|
|
||||||
|
# Add line breaks after block-level elements to ensure pauses in speech
|
||||||
|
for tag in slice_soup.find_all(
|
||||||
|
["p", "div", "h1", "h2", "h3", "h4", "h5", "h6", "li", "blockquote"]
|
||||||
|
):
|
||||||
tag.append("\n\n")
|
tag.append("\n\n")
|
||||||
|
|
||||||
for ol in slice_soup.find_all("ol"):
|
for ol in slice_soup.find_all("ol"):
|
||||||
|
|||||||
@@ -1023,8 +1023,13 @@ class EpubExtractor:
|
|||||||
if not html:
|
if not html:
|
||||||
return ""
|
return ""
|
||||||
soup = BeautifulSoup(html, "html.parser")
|
soup = BeautifulSoup(html, "html.parser")
|
||||||
for tag in soup.find_all(["p", "div"]):
|
|
||||||
|
# Add line breaks after block-level elements to ensure pauses in speech
|
||||||
|
for tag in soup.find_all(
|
||||||
|
["p", "div", "h1", "h2", "h3", "h4", "h5", "h6", "li", "blockquote"]
|
||||||
|
):
|
||||||
tag.append("\n\n")
|
tag.append("\n\n")
|
||||||
|
|
||||||
for ol in soup.find_all("ol"):
|
for ol in soup.find_all("ol"):
|
||||||
start_attr = ol.get("start")
|
start_attr = ol.get("start")
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user