Fixed bookmarking with audio books.

This commit is contained in:
Storm Dragon
2025-10-16 16:30:58 -04:00
parent 542764be2a
commit 0bdc5bdf17
9 changed files with 648 additions and 178 deletions

View File

@@ -11,11 +11,24 @@ import subprocess
import wave
import io
import struct
import shutil
from .text_validator import is_valid_text
class TtsEngine:
"""Text-to-speech engine using piper-tts"""
@staticmethod
def is_available():
"""
Check if piper-tts is available on the system
Returns:
bool: True if piper-tts is installed, False otherwise
"""
return shutil.which('piper-tts') is not None
def __init__(self, modelPath="/usr/share/piper-voices/en/en_US/hfc_male/medium/en_US-hfc_male-medium.onnx"):
"""
Initialize TTS engine
@@ -41,7 +54,7 @@ class TtsEngine:
Raises:
RuntimeError: If piper-tts fails
"""
if not text.strip():
if not is_valid_text(text):
return None
# Safety: Limit text size to prevent excessive memory usage