@danhachuel/thunderbolt 0.3.79 → 0.3.81
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.
|
@@ -807,6 +807,8 @@ def _run_video_helper(task: dict[str, Any]) -> Path:
|
|
|
807
807
|
"MPT_PEXELS_API_KEYS": json.dumps(source_keys, ensure_ascii=False) if route == "pexels" and source_keys else "",
|
|
808
808
|
"MPT_PIXABAY_API_KEY": source_keys[0] if route == "pixabay" and source_keys else "",
|
|
809
809
|
"MPT_PIXABAY_API_KEYS": json.dumps(source_keys, ensure_ascii=False) if route == "pixabay" and source_keys else "",
|
|
810
|
+
"MPT_AZURE_SPEECH_KEY": str(settings.get("azure_speech_key") or "").strip(),
|
|
811
|
+
"MPT_AZURE_SPEECH_REGION": str(settings.get("azure_speech_region") or "").strip(),
|
|
810
812
|
}
|
|
811
813
|
for key, value in env_values.items():
|
|
812
814
|
if value:
|
package/package.json
CHANGED
|
@@ -116,10 +116,11 @@ def chunk_character_limit(rate: float) -> int:
|
|
|
116
116
|
def _build_ssml(text: str, voice: str, rate: float) -> str:
|
|
117
117
|
parts = voice.split("-", 2)
|
|
118
118
|
locale = "-".join(parts[:2]) if len(parts) >= 2 else "en-US"
|
|
119
|
+
escaped_voice = escape(voice, {'"': """})
|
|
119
120
|
return (
|
|
120
121
|
'<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" '
|
|
121
122
|
f'xml:lang="{escape(locale)}">'
|
|
122
|
-
f'<voice name="{
|
|
123
|
+
f'<voice name="{escaped_voice}">'
|
|
123
124
|
f'<prosody rate="{_normalise_rate(rate):g}">{escape(text)}</prosody>'
|
|
124
125
|
"</voice></speak>"
|
|
125
126
|
)
|
package/seed/skills/mpt_agent.py
CHANGED
|
@@ -203,6 +203,27 @@ def _replace_config_value(text: str, key: str, value: object) -> str:
|
|
|
203
203
|
return pattern.sub(lambda match: f"{match.group(1)}{encoded}", text, count=1)
|
|
204
204
|
|
|
205
205
|
|
|
206
|
+
def _replace_toml_section_value(text: str, section: str, key: str, value: object) -> str:
|
|
207
|
+
"""Replace or append a scalar value inside one TOML section."""
|
|
208
|
+
encoded = json.dumps(value, ensure_ascii=False)
|
|
209
|
+
section_pattern = re.compile(
|
|
210
|
+
rf"(?ms)^\[{re.escape(section)}\][ \t]*(?:\n|$)(.*?)(?=^\[|\Z)"
|
|
211
|
+
)
|
|
212
|
+
section_match = section_pattern.search(text)
|
|
213
|
+
if section_match is None:
|
|
214
|
+
separator = "" if not text.strip() else "\n\n"
|
|
215
|
+
return f"{text.rstrip()}{separator}[{section}]\n{key} = {encoded}\n"
|
|
216
|
+
body = section_match.group(1)
|
|
217
|
+
value_pattern = re.compile(rf"(?m)^({re.escape(key)}\s*=\s*).*$")
|
|
218
|
+
if value_pattern.search(body):
|
|
219
|
+
updated_body = value_pattern.sub(
|
|
220
|
+
lambda match: f"{match.group(1)}{encoded}", body, count=1
|
|
221
|
+
)
|
|
222
|
+
else:
|
|
223
|
+
updated_body = f"{body.rstrip()}\n{key} = {encoded}\n"
|
|
224
|
+
return f"{text[:section_match.start(1)]}{updated_body}{text[section_match.end(1):]}"
|
|
225
|
+
|
|
226
|
+
|
|
206
227
|
def _has_configured_value(value: str) -> bool:
|
|
207
228
|
"""Treat empty strings and whitespace-only key arrays as unconfigured."""
|
|
208
229
|
if not value:
|
|
@@ -237,13 +258,15 @@ def apply_environment_config(config_path: Path) -> None:
|
|
|
237
258
|
model_name = os.environ.get("MPT_LLM_MODEL_NAME", "").strip()
|
|
238
259
|
pexels_key = os.environ.get("MPT_PEXELS_API_KEY", "").strip()
|
|
239
260
|
pixabay_key = os.environ.get("MPT_PIXABAY_API_KEY", "").strip()
|
|
261
|
+
azure_speech_key = os.environ.get("MPT_AZURE_SPEECH_KEY", "").strip()
|
|
262
|
+
azure_speech_region = os.environ.get("MPT_AZURE_SPEECH_REGION", "").strip()
|
|
240
263
|
pexels_keys = _parse_string_list(os.environ.get("MPT_PEXELS_API_KEYS", ""))
|
|
241
264
|
pixabay_keys = _parse_string_list(os.environ.get("MPT_PIXABAY_API_KEYS", ""))
|
|
242
265
|
if not pexels_keys and pexels_key:
|
|
243
266
|
pexels_keys = [pexels_key]
|
|
244
267
|
if not pixabay_keys and pixabay_key:
|
|
245
268
|
pixabay_keys = [pixabay_key]
|
|
246
|
-
if not any((provider, llm_key, base_url, model_name, pexels_keys, pixabay_keys)):
|
|
269
|
+
if not any((provider, llm_key, base_url, model_name, pexels_keys, pixabay_keys, azure_speech_key, azure_speech_region)):
|
|
247
270
|
return
|
|
248
271
|
|
|
249
272
|
text = config_path.read_text(encoding="utf-8")
|
|
@@ -268,6 +291,12 @@ def apply_environment_config(config_path: Path) -> None:
|
|
|
268
291
|
if pixabay_keys:
|
|
269
292
|
text = _replace_config_value(text, "pixabay_api_keys", pixabay_keys)
|
|
270
293
|
changes.append("pixabay_api_keys")
|
|
294
|
+
if azure_speech_key:
|
|
295
|
+
text = _replace_toml_section_value(text, "azure", "speech_key", azure_speech_key)
|
|
296
|
+
changes.append("azure.speech_key")
|
|
297
|
+
if azure_speech_region:
|
|
298
|
+
text = _replace_toml_section_value(text, "azure", "speech_region", azure_speech_region)
|
|
299
|
+
changes.append("azure.speech_region")
|
|
271
300
|
_atomic_write_text(config_path, text)
|
|
272
301
|
log("updated configuration fields: " + ", ".join(changes))
|
|
273
302
|
|