lollms-client 1.3.4__py3-none-any.whl → 1.3.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of lollms-client might be problematic. Click here for more details.
- lollms_client/__init__.py +1 -1
- lollms_client/llm_bindings/llamacpp/__init__.py +354 -233
- lollms_client/llm_bindings/lollms/__init__.py +152 -153
- lollms_client/lollms_core.py +162 -76
- lollms_client/lollms_discussion.py +2 -2
- lollms_client/lollms_llm_binding.py +3 -3
- lollms_client/lollms_tts_binding.py +80 -67
- lollms_client/tts_bindings/bark/__init__.py +110 -329
- lollms_client/tts_bindings/bark/server/install_bark.py +64 -0
- lollms_client/tts_bindings/bark/server/main.py +311 -0
- lollms_client/tts_bindings/piper_tts/__init__.py +115 -335
- lollms_client/tts_bindings/piper_tts/server/install_piper.py +92 -0
- lollms_client/tts_bindings/piper_tts/server/main.py +425 -0
- lollms_client/tts_bindings/piper_tts/server/setup_voices.py +67 -0
- lollms_client/tts_bindings/xtts/__init__.py +99 -305
- lollms_client/tts_bindings/xtts/server/main.py +314 -0
- lollms_client/tts_bindings/xtts/server/setup_voices.py +67 -0
- {lollms_client-1.3.4.dist-info → lollms_client-1.3.7.dist-info}/METADATA +1 -1
- {lollms_client-1.3.4.dist-info → lollms_client-1.3.7.dist-info}/RECORD +22 -15
- {lollms_client-1.3.4.dist-info → lollms_client-1.3.7.dist-info}/WHEEL +0 -0
- {lollms_client-1.3.4.dist-info → lollms_client-1.3.7.dist-info}/licenses/LICENSE +0 -0
- {lollms_client-1.3.4.dist-info → lollms_client-1.3.7.dist-info}/top_level.txt +0 -0
|
@@ -34,13 +34,13 @@ def load_known_contexts():
|
|
|
34
34
|
return known_contexts
|
|
35
35
|
except FileNotFoundError:
|
|
36
36
|
print(f"Error: File not found at {file_path}")
|
|
37
|
-
return
|
|
37
|
+
return []
|
|
38
38
|
except json.JSONDecodeError:
|
|
39
39
|
print(f"Error: Could not decode JSON from {file_path}")
|
|
40
|
-
return
|
|
40
|
+
return []
|
|
41
41
|
except Exception as e:
|
|
42
42
|
print(f"An unexpected error occurred: {e}")
|
|
43
|
-
return
|
|
43
|
+
return []
|
|
44
44
|
|
|
45
45
|
class LollmsLLMBinding(ABC):
|
|
46
46
|
"""Abstract base class for all LOLLMS LLM bindings"""
|
|
@@ -1,77 +1,50 @@
|
|
|
1
|
-
# lollms_client/lollms_tts_binding.py
|
|
2
1
|
from abc import ABC, abstractmethod
|
|
3
2
|
import importlib
|
|
4
3
|
from pathlib import Path
|
|
5
|
-
from typing import Optional, List, Dict, Any, Union
|
|
4
|
+
from typing import Optional, List, Dict, Any, Union
|
|
5
|
+
import yaml
|
|
6
6
|
from ascii_colors import trace_exception
|
|
7
7
|
|
|
8
8
|
class LollmsTTSBinding(ABC):
|
|
9
|
-
"""Abstract base class for all LOLLMS Text-to-Speech bindings."""
|
|
10
|
-
|
|
11
9
|
def __init__(self,
|
|
12
|
-
binding_name:str="unknown"
|
|
13
|
-
|
|
14
|
-
Initialize the LollmsTTSBinding base class.
|
|
15
|
-
|
|
16
|
-
Args:
|
|
17
|
-
binding_name (Optional[str]): The binding name
|
|
18
|
-
"""
|
|
10
|
+
binding_name: str = "unknown",
|
|
11
|
+
**kwargs):
|
|
19
12
|
self.binding_name = binding_name
|
|
13
|
+
self.settings = kwargs
|
|
20
14
|
|
|
21
15
|
@abstractmethod
|
|
22
|
-
def generate_audio(self,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Args:
|
|
27
|
-
text (str): The text content to synthesize.
|
|
28
|
-
voice (Optional[str]): The specific voice or model to use (if supported by the binding).
|
|
29
|
-
If None, a default voice might be used.
|
|
30
|
-
**kwargs: Additional binding-specific parameters.
|
|
31
|
-
|
|
32
|
-
Returns:
|
|
33
|
-
bytes: The generated audio data (e.g., in WAV or MP3 format).
|
|
34
|
-
|
|
35
|
-
Raises:
|
|
36
|
-
Exception: If audio generation fails.
|
|
37
|
-
"""
|
|
16
|
+
def generate_audio(self,
|
|
17
|
+
text: str,
|
|
18
|
+
voice: Optional[str] = None,
|
|
19
|
+
**kwargs) -> bytes:
|
|
38
20
|
pass
|
|
39
21
|
|
|
40
22
|
@abstractmethod
|
|
41
23
|
def list_voices(self, **kwargs) -> List[str]:
|
|
42
|
-
"""
|
|
43
|
-
Lists the available voices or TTS models supported by the binding.
|
|
44
|
-
|
|
45
|
-
Args:
|
|
46
|
-
**kwargs: Additional binding-specific parameters.
|
|
47
|
-
|
|
48
|
-
Returns:
|
|
49
|
-
List[str]: A list of available voice/model identifiers.
|
|
50
|
-
"""
|
|
51
24
|
pass
|
|
52
25
|
|
|
53
|
-
|
|
54
|
-
|
|
26
|
+
@abstractmethod
|
|
27
|
+
def list_models(self, **kwargs) -> List[str]:
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
def get_settings(self, **kwargs) -> Dict[str, Any]:
|
|
31
|
+
return self.settings
|
|
55
32
|
|
|
56
|
-
def
|
|
57
|
-
|
|
58
|
-
|
|
33
|
+
def set_settings(self, settings: Dict[str, Any], **kwargs) -> bool:
|
|
34
|
+
self.settings.update(settings)
|
|
35
|
+
return True
|
|
59
36
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
Defaults to the "tts_bindings" subdirectory.
|
|
63
|
-
"""
|
|
37
|
+
class LollmsTTSBindingManager:
|
|
38
|
+
def __init__(self, tts_bindings_dir: Union[str, Path] = Path(__file__).parent / "tts_bindings"):
|
|
64
39
|
self.tts_bindings_dir = Path(tts_bindings_dir)
|
|
65
40
|
self.available_bindings = {}
|
|
66
41
|
|
|
67
42
|
def _load_binding(self, binding_name: str):
|
|
68
|
-
"""Dynamically load a specific TTS binding implementation."""
|
|
69
43
|
binding_dir = self.tts_bindings_dir / binding_name
|
|
70
44
|
if binding_dir.is_dir() and (binding_dir / "__init__.py").exists():
|
|
71
45
|
try:
|
|
72
|
-
# Adjust module path for dynamic loading
|
|
73
46
|
module = importlib.import_module(f"lollms_client.tts_bindings.{binding_name}")
|
|
74
|
-
binding_class = getattr(module, module.BindingName)
|
|
47
|
+
binding_class = getattr(module, module.BindingName)
|
|
75
48
|
self.available_bindings[binding_name] = binding_class
|
|
76
49
|
except Exception as e:
|
|
77
50
|
trace_exception(e)
|
|
@@ -79,36 +52,76 @@ class LollmsTTSBindingManager:
|
|
|
79
52
|
|
|
80
53
|
def create_binding(self,
|
|
81
54
|
binding_name: str,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
Args:
|
|
87
|
-
binding_name (str): Name of the TTS binding to create.
|
|
88
|
-
**kwargs: Additional parameters specific to the binding's __init__.
|
|
89
|
-
|
|
90
|
-
Returns:
|
|
91
|
-
Optional[LollmsTTSBinding]: Binding instance or None if creation failed.
|
|
92
|
-
"""
|
|
55
|
+
config: Dict[str, Any] = None) -> Optional[LollmsTTSBinding]:
|
|
56
|
+
if config is None:
|
|
57
|
+
config = {}
|
|
58
|
+
|
|
93
59
|
if binding_name not in self.available_bindings:
|
|
94
60
|
self._load_binding(binding_name)
|
|
95
61
|
|
|
96
62
|
binding_class = self.available_bindings.get(binding_name)
|
|
97
63
|
if binding_class:
|
|
98
64
|
try:
|
|
99
|
-
return binding_class(**
|
|
65
|
+
return binding_class(**config)
|
|
100
66
|
except Exception as e:
|
|
101
67
|
trace_exception(e)
|
|
102
68
|
print(f"Failed to instantiate TTS binding {binding_name}: {str(e)}")
|
|
103
69
|
return None
|
|
104
70
|
return None
|
|
105
71
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
72
|
+
@staticmethod
|
|
73
|
+
def _get_fallback_description(binding_name: str) -> Dict:
|
|
74
|
+
return {
|
|
75
|
+
"binding_name": binding_name,
|
|
76
|
+
"title": binding_name.replace("_", " ").title(),
|
|
77
|
+
"author": "Unknown",
|
|
78
|
+
"version": "N/A",
|
|
79
|
+
"description": f"A binding for {binding_name}. No description.yaml file was found.",
|
|
80
|
+
"input_parameters": [
|
|
81
|
+
{
|
|
82
|
+
"name": "model_name",
|
|
83
|
+
"type": "str",
|
|
84
|
+
"description": "The model name or ID to be used.",
|
|
85
|
+
"mandatory": False,
|
|
86
|
+
"default": ""
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
"generate_audio_parameters": []
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@staticmethod
|
|
93
|
+
def get_bindings_list(tts_bindings_dir: Union[str, Path]) -> List[Dict]:
|
|
94
|
+
bindings_dir = Path(tts_bindings_dir)
|
|
95
|
+
if not bindings_dir.is_dir():
|
|
96
|
+
return []
|
|
97
|
+
|
|
98
|
+
bindings_list = []
|
|
99
|
+
for binding_folder in bindings_dir.iterdir():
|
|
100
|
+
if binding_folder.is_dir() and (binding_folder / "__init__.py").exists():
|
|
101
|
+
binding_name = binding_folder.name
|
|
102
|
+
description_file = binding_folder / "description.yaml"
|
|
103
|
+
|
|
104
|
+
binding_info = {}
|
|
105
|
+
if description_file.exists():
|
|
106
|
+
try:
|
|
107
|
+
with open(description_file, 'r', encoding='utf-8') as f:
|
|
108
|
+
binding_info = yaml.safe_load(f)
|
|
109
|
+
binding_info['binding_name'] = binding_name
|
|
110
|
+
except Exception as e:
|
|
111
|
+
print(f"Error loading description.yaml for {binding_name}: {e}")
|
|
112
|
+
binding_info = LollmsTTSBindingManager._get_fallback_description(binding_name)
|
|
113
|
+
else:
|
|
114
|
+
binding_info = LollmsTTSBindingManager._get_fallback_description(binding_name)
|
|
115
|
+
|
|
116
|
+
bindings_list.append(binding_info)
|
|
117
|
+
|
|
118
|
+
return sorted(bindings_list, key=lambda b: b.get('title', b['binding_name']))
|
|
109
119
|
|
|
110
|
-
|
|
111
|
-
list[str]: List of binding names.
|
|
112
|
-
"""
|
|
120
|
+
def get_available_bindings(self) -> list[str]:
|
|
113
121
|
return [binding_dir.name for binding_dir in self.tts_bindings_dir.iterdir()
|
|
114
|
-
if binding_dir.is_dir() and (binding_dir / "__init__.py").exists()]
|
|
122
|
+
if binding_dir.is_dir() and (binding_dir / "__init__.py").exists()]
|
|
123
|
+
|
|
124
|
+
def get_available_bindings(tts_bindings_dir: Union[str, Path] = None) -> List[Dict]:
|
|
125
|
+
if tts_bindings_dir is None:
|
|
126
|
+
tts_bindings_dir = Path(__file__).resolve().parent / "tts_bindings"
|
|
127
|
+
return LollmsTTSBindingManager.get_bindings_list(tts_bindings_dir)
|