mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow using the special voice name __skip__ to not vocalize text
This commit is contained in:
parent
358a202268
commit
c2da702b0f
@ -61,6 +61,7 @@ ignored_tag_names = frozenset({
|
|||||||
})
|
})
|
||||||
id_prefix = 'cttsw-'
|
id_prefix = 'cttsw-'
|
||||||
data_name = 'data-calibre-tts'
|
data_name = 'data-calibre-tts'
|
||||||
|
skip_name = '__skip__'
|
||||||
|
|
||||||
|
|
||||||
def unmark_sentences_in_html(root):
|
def unmark_sentences_in_html(root):
|
||||||
@ -117,7 +118,7 @@ def mark_sentences_in_html(root, lang: str = '', voice: str = '') -> list[Senten
|
|||||||
self.pos = 0
|
self.pos = 0
|
||||||
for start, length in split_into_sentences_for_tts_embed(text, self.lang):
|
for start, length in split_into_sentences_for_tts_embed(text, self.lang):
|
||||||
stext = text[start:start+length]
|
stext = text[start:start+length]
|
||||||
if stext.strip():
|
if stext.strip() and self.voice != '__skip__':
|
||||||
elem_id = self.wrap_sentence(start, length)
|
elem_id = self.wrap_sentence(start, length)
|
||||||
ans.append(Sentence(elem_id, stext, self.lang, self.voice))
|
ans.append(Sentence(elem_id, stext, self.lang, self.voice))
|
||||||
if self.has_tail:
|
if self.has_tail:
|
||||||
@ -127,7 +128,7 @@ def mark_sentences_in_html(root, lang: str = '', voice: str = '') -> list[Senten
|
|||||||
for start, length in split_into_sentences_for_tts_embed(self.elem.tail, self.parent_lang):
|
for start, length in split_into_sentences_for_tts_embed(self.elem.tail, self.parent_lang):
|
||||||
end = start + length
|
end = start + length
|
||||||
text = self.elem.tail[start:end]
|
text = self.elem.tail[start:end]
|
||||||
if not text.strip():
|
if not text.strip() or self.parent_voice == '__skip__':
|
||||||
continue
|
continue
|
||||||
if before is None:
|
if before is None:
|
||||||
before = self.elem.tail[:start]
|
before = self.elem.tail[:start]
|
||||||
|
@ -17,6 +17,7 @@ from calibre.gui2.widgets import BusyCursor
|
|||||||
class EngineSettingsWidget(QWidget):
|
class EngineSettingsWidget(QWidget):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
from calibre.ebooks.oeb.polish.tts import skip_name
|
||||||
from calibre.gui2.tts.config import EmbeddingConfig
|
from calibre.gui2.tts.config import EmbeddingConfig
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.h = h = QHBoxLayout(self)
|
self.h = h = QHBoxLayout(self)
|
||||||
@ -33,13 +34,14 @@ audio overlays, such as the calibre viewer, will be able to hear the text read t
|
|||||||
|
|
||||||
<p>You can mark different passages to be spoken by different voices as shown in the example below:
|
<p>You can mark different passages to be spoken by different voices as shown in the example below:
|
||||||
|
|
||||||
<div><code><p data-calibre-tts="{0}">This will be voiced by "{0}"</p></code></div>
|
<div><code><p data-calibre-tts="{0}">This will be voiced by "{0}".</p></code></div>
|
||||||
<div><code><p data-calibre-tts="{1}">This will be voiced by "{1}"</p></code></div>
|
<div><code><p data-calibre-tts="{1}">This will be voiced by "{1}".</p></code></div>
|
||||||
|
<div><code><p data-calibre-tts="{2}">This text will not be voiced at all.</p></code></div>
|
||||||
|
|
||||||
<p style="font-size: small">Note that generating the Text-to-speech audio will be quite slow,
|
<p style="font-size: small">Note that generating the Text-to-speech audio will be quite slow,
|
||||||
at the rate of approximately one sentence per couple of seconds, depending on your computer's hardware,
|
at the rate of approximately one sentence per couple of seconds, depending on your computer's hardware,
|
||||||
so consider leave it running overnight.
|
so consider leave it running overnight.
|
||||||
''').format('cory', 'ryan'))
|
''').format('cory', 'ryan', skip_name))
|
||||||
self.save_settings = c.save_settings
|
self.save_settings = c.save_settings
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user