Fixed bookmarking with audio books.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user