agentvibes 5.13.0 → 5.14.0
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.
- package/.claude/audio/ui/CREDITS.txt +16 -16
- package/.claude/commands/agent-vibes-bmad-voices.md +117 -117
- package/.claude/commands/agent-vibes-rdp.md +24 -24
- package/.claude/config/audio-effects.cfg.sample +52 -52
- package/.claude/docs/TERMUX_SETUP.md +408 -408
- package/.claude/github-star-reminder.txt +1 -1
- package/.claude/hooks/kokoro-server.py +219 -219
- package/.claude/hooks/kokoro-tts.py +141 -141
- package/.claude/hooks/party-stage-roster.py +328 -328
- package/.claude/hooks/play-tts-kokoro.sh +7 -2
- package/.claude/hooks/play-tts-ssh-remote.sh +38 -3
- package/.claude/hooks/requirements.txt +6 -6
- package/.claude/hooks/soprano-gradio-synth.py +139 -139
- package/.claude/hooks/translator.py +237 -237
- package/.claude/hooks-windows/kokoro-server.py +219 -219
- package/.claude/hooks-windows/kokoro-tts.py +107 -107
- package/.claude/hooks-windows/play-tts.ps1 +17 -0
- package/.claude/hooks-windows/soprano-gradio-synth.py +153 -153
- package/.claude/verbosity.txt +1 -1
- package/.clawdbot/README.md +105 -105
- package/CLAUDE.md +84 -176
- package/README.md +27 -2
- package/RELEASE_NOTES.md +86 -0
- package/WINDOWS-SETUP.md +208 -208
- package/bin/agent-vibes +39 -39
- package/bin/mcp-server.js +121 -121
- package/bin/test-bmad-pr +78 -78
- package/mcp-server/QUICK_START.md +203 -203
- package/mcp-server/README.md +345 -345
- package/mcp-server/examples/claude_desktop_config.json +11 -11
- package/mcp-server/examples/claude_desktop_config_piper.json +9 -9
- package/mcp-server/examples/custom_instructions.md +169 -169
- package/mcp-server/install-deps.js +12 -2
- package/mcp-server/server.py +2111 -2085
- package/mcp-server/test_mcp_correctness.py +504 -504
- package/mcp-server/test_windows_script_parity.py +339 -339
- package/package.json +7 -4
- package/setup-ssh-receiver.ps1 +259 -0
- package/setup-windows.ps1 +39 -29
- package/src/cli/list-personalities.js +110 -110
- package/src/commands/bmad-voices.js +394 -394
- package/src/console/brand-colors.js +13 -13
- package/src/console/constants/personalities.js +44 -44
- package/src/console/tabs/agents-tab.js +14 -4
- package/src/console/tabs/help-tab.js +314 -314
- package/src/console/tabs/readme-tab.js +272 -272
- package/src/console/tabs/settings-tab.js +31 -6
- package/src/console/tabs/setup-tab.js +154 -32
- package/src/console/tabs/voices-tab.js +48 -6
- package/src/console/widgets/destroy-list.js +25 -25
- package/src/console/widgets/notice.js +55 -55
- package/src/installer/language-screen.js +31 -31
- package/src/installer/music-file-input.js +304 -304
- package/src/installer.js +103 -43
- package/src/services/language-service.js +47 -47
- package/src/services/llm-provider-service.js +4 -1
- package/src/services/provider-voice-catalog.js +9 -5
- package/src/utils/audio-format-validator.js +277 -277
- package/src/utils/dependency-checker.js +469 -469
- package/src/utils/file-ownership-verifier.js +358 -358
- package/src/utils/music-file-validator.js +285 -285
- package/src/utils/preview-list-prompt.js +144 -144
- package/src/utils/secure-music-storage.js +412 -412
- package/templates/agentvibes-receiver.ps1 +311 -0
- package/templates/agentvibes-receiver.sh +297 -297
- package/voice-assignments.json +8244 -8244
- package/.agentvibes/config.json +0 -17
- package/.agentvibes/install-manifest.json +0 -342
- package/.claude/config/audio-effects.cfg +0 -7
- package/.claude/config/audio-effects.cfg.bak-kokoro +0 -7
- package/.claude/config/background-music-enabled.txt +0 -1
- package/.claude/config/background-music-position.txt +0 -27
- package/.claude/config/background-music-volume.txt +0 -1
- package/.claude/config/background-music.cfg +0 -1
- package/.claude/config/background-music.txt +0 -1
- package/.claude/config/language.txt +0 -1
- package/.claude/config/personality.txt +0 -1
- package/.claude/config/reverb-level.txt +0 -1
- package/.claude/config/tts-speech-rate.txt +0 -1
- package/.claude/config/tts-verbosity.txt +0 -1
- package/.claude/hooks-windows/audio-cache-utils.ps1.user.bak +0 -119
- package/.claude/hooks-windows/soprano-gradio-synth.py.user.bak +0 -153
|
@@ -47,8 +47,13 @@ if [[ -z "$PYTHON_BIN" ]]; then
|
|
|
47
47
|
echo " or set AGENTVIBES_PYTHON=/path/to/python.exe if it's installed elsewhere." >&2
|
|
48
48
|
exit 2
|
|
49
49
|
fi
|
|
50
|
-
# Check kokoro is installed (use find_spec to avoid slow torch import)
|
|
51
|
-
|
|
50
|
+
# Check kokoro is installed (use find_spec to avoid slow torch import).
|
|
51
|
+
# Skipped in AGENTVIBES_TEST_MODE: the hermetic sentinel tests emit a fake
|
|
52
|
+
# AV_OUTPUT below without real synthesis, so kokoro need not be installed on the
|
|
53
|
+
# runner (mirrors the TEST_MODE guards in play-tts-piper.sh; CI has Piper but not
|
|
54
|
+
# the heavy Kokoro deps).
|
|
55
|
+
if [[ "${AGENTVIBES_TEST_MODE:-false}" != "true" ]] && \
|
|
56
|
+
! "$PYTHON_BIN" -c "import importlib.util; exit(0 if importlib.util.find_spec('kokoro') else 1)" 2>/dev/null; then
|
|
52
57
|
echo "❌ Kokoro TTS module not installed for: $PYTHON_BIN" >&2
|
|
53
58
|
echo " Install with: ${SCRIPT_DIR}/kokoro-installer.sh" >&2
|
|
54
59
|
echo " Or manually: \"$PYTHON_BIN\" -m pip install kokoro soundfile numpy" >&2
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
set -euo pipefail
|
|
16
16
|
|
|
17
17
|
TEXT="${1:-}"
|
|
18
|
+
_VOICE_ARG="${2:-}" # raw voice as passed (empty on normal hook TTS)
|
|
18
19
|
VOICE="${2:-en_US-lessac-medium}"
|
|
19
20
|
AGENT_NAME="${3:-default}"
|
|
20
21
|
AGENT_PROFILE_FILE="${4:-}"
|
|
@@ -305,10 +306,39 @@ fi
|
|
|
305
306
|
|
|
306
307
|
# Read the TTS provider the RECEIVER should use to generate audio.
|
|
307
308
|
# This is separate from the sender's own provider (which is "ssh-remote").
|
|
308
|
-
#
|
|
309
|
+
# Priority: one-off caller override (a voice-picker PREVIEW forces the previewed
|
|
310
|
+
# voice's own engine for THIS send only) → project receiver-provider.txt →
|
|
311
|
+
# home receiver-provider.txt → "piper". The override intentionally does NOT
|
|
312
|
+
# write any config: a preview must preview, never change the persisted setting.
|
|
309
313
|
PROVIDER=""
|
|
314
|
+
if [[ -n "${AGENTVIBES_RECEIVER_PROVIDER_OVERRIDE:-}" ]]; then
|
|
315
|
+
PROVIDER="$AGENTVIBES_RECEIVER_PROVIDER_OVERRIDE"
|
|
316
|
+
fi
|
|
317
|
+
# Voice->engine coupling (mirrors the guard in play-tts.ps1): a Kokoro-format
|
|
318
|
+
# voice id (strict lang/gender prefix, e.g. af_bella) or a Piper voice (locale+
|
|
319
|
+
# hyphen like en_US-lessac-medium, or an ::Speaker suffix) can ONLY be
|
|
320
|
+
# synthesised by that engine — so the voice itself decides the receiver engine,
|
|
321
|
+
# overriding a stale/mislabeled provider default (e.g. an old console that always
|
|
322
|
+
# sends windows-sapi). Names that don't encode an engine (SAPI/macOS names) fall
|
|
323
|
+
# through to the configured provider below.
|
|
324
|
+
#
|
|
325
|
+
# GATED on an EXPLICIT voice arg ($2): normal hook TTS passes no voice, and VOICE
|
|
326
|
+
# then defaults to a piper id — coupling on that default would wrongly force
|
|
327
|
+
# `piper` on EVERY normal utterance and shadow receiver-provider.txt (a kokoro/
|
|
328
|
+
# SAPI receiver would silently regress to piper). Only a caller that passed a
|
|
329
|
+
# real voice (every voice-picker preview does) gets voice->engine coupling.
|
|
330
|
+
if [[ -z "$PROVIDER" && -n "$_VOICE_ARG" ]]; then
|
|
331
|
+
_v_nospk="${VOICE%%::*}" # strip any ::Speaker-ID suffix before matching
|
|
332
|
+
# Kokoro ids use a fixed lang/gender prefix set (mirrors play-tts.sh) — a loose
|
|
333
|
+
# `^[a-z]{2}_...` would misclassify a custom piper model like `my_voice`.
|
|
334
|
+
if [[ "$_v_nospk" =~ ^(af|am|bf|bm|jf|jm|kf|km|zf|zm|ff|fm|hf|hm|if|im|pf|pm|ef|em|nf|nm)_[a-z0-9_]+$ ]]; then
|
|
335
|
+
PROVIDER="kokoro"
|
|
336
|
+
elif [[ "$VOICE" == *"::"* ]] || [[ "$_v_nospk" =~ ^[a-z]{2}_[A-Za-z]{2}-. ]]; then
|
|
337
|
+
PROVIDER="piper"
|
|
338
|
+
fi
|
|
339
|
+
fi
|
|
310
340
|
RECEIVER_PROVIDER_FILE="$PROJECT_ROOT/.agentvibes/config/receiver-provider.txt"
|
|
311
|
-
if [[ -f "$RECEIVER_PROVIDER_FILE" ]]; then
|
|
341
|
+
if [[ -z "$PROVIDER" && -f "$RECEIVER_PROVIDER_FILE" ]]; then
|
|
312
342
|
PROVIDER=$(cat "$RECEIVER_PROVIDER_FILE" 2>/dev/null || true)
|
|
313
343
|
fi
|
|
314
344
|
# Also check home-level config
|
|
@@ -392,7 +422,12 @@ fi
|
|
|
392
422
|
# SECURITY: Use jq if available for safe JSON construction, else manual escaping
|
|
393
423
|
build_json_payload() {
|
|
394
424
|
if command -v jq &>/dev/null; then
|
|
395
|
-
jq -
|
|
425
|
+
# On Windows git-bash, native jq.exe triggers MSYS2 path-conversion of any
|
|
426
|
+
# POSIX-looking --arg value (projectPath "/c/proj" becomes "C:/proj", music
|
|
427
|
+
# file paths likewise), silently corrupting the JSON string the receiver
|
|
428
|
+
# reads. Excluding all args from conversion passes every --arg literally.
|
|
429
|
+
# Both vars are no-ops on Linux/macOS.
|
|
430
|
+
MSYS2_ARG_CONV_EXCL='*' MSYS_NO_PATHCONV=1 jq -n \
|
|
396
431
|
--arg text "$TEXT" \
|
|
397
432
|
--arg voice "$VOICE" \
|
|
398
433
|
--arg effects "$SOX_EFFECTS" \
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# AgentVibes TTS Hooks Requirements
|
|
2
|
-
# Install with: pip install -r requirements.txt
|
|
3
|
-
|
|
4
|
-
# Translation support for multi-language TTS and learning mode
|
|
5
|
-
deep-translator>=1.11.4
|
|
6
|
-
langdetect>=1.0.9
|
|
1
|
+
# AgentVibes TTS Hooks Requirements
|
|
2
|
+
# Install with: pip install -r requirements.txt
|
|
3
|
+
|
|
4
|
+
# Translation support for multi-language TTS and learning mode
|
|
5
|
+
deep-translator>=1.11.4
|
|
6
|
+
langdetect>=1.0.9
|
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
#
|
|
3
|
-
# File: .claude/hooks/soprano-gradio-synth.py
|
|
4
|
-
#
|
|
5
|
-
# AgentVibes - Finally, your AI Agents can Talk Back!
|
|
6
|
-
# Website: https://agentvibes.org
|
|
7
|
-
# Repository: https://github.com/paulpreibisch/AgentVibes
|
|
8
|
-
#
|
|
9
|
-
# Co-created by Paul Preibisch with Claude AI
|
|
10
|
-
# Copyright (c) 2025 Paul Preibisch
|
|
11
|
-
#
|
|
12
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
-
# you may not use this file except in compliance with the License.
|
|
14
|
-
# You may obtain a copy of the License at
|
|
15
|
-
#
|
|
16
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
-
#
|
|
18
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
19
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
-
# See the License for the specific language governing permissions and
|
|
22
|
-
# limitations under the License.
|
|
23
|
-
#
|
|
24
|
-
# ---
|
|
25
|
-
#
|
|
26
|
-
# Soprano Gradio WebUI synthesizer helper.
|
|
27
|
-
# Calls the Soprano WebUI's Gradio API and saves the result as a WAV file.
|
|
28
|
-
# Uses only Python stdlib (json, sys, urllib) — no extra dependencies.
|
|
29
|
-
#
|
|
30
|
-
# Usage: python3 soprano-gradio-synth.py "text to speak" output.wav [port]
|
|
31
|
-
#
|
|
32
|
-
"""
|
|
33
|
-
Soprano Gradio WebUI synthesizer helper for AgentVibes.
|
|
34
|
-
|
|
35
|
-
Calls the Soprano WebUI's Gradio API via the Server-Sent Events (SSE) protocol
|
|
36
|
-
and downloads the generated audio as a WAV file.
|
|
37
|
-
|
|
38
|
-
Flow:
|
|
39
|
-
1. Submit generation request → get event_id
|
|
40
|
-
2. Poll SSE stream for audio file URL
|
|
41
|
-
3. Download WAV file to output path
|
|
42
|
-
|
|
43
|
-
See: https://github.com/ekwek1/soprano
|
|
44
|
-
"""
|
|
45
|
-
import json
|
|
46
|
-
import sys
|
|
47
|
-
import urllib.request
|
|
48
|
-
import urllib.error
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def synth(text: str, output_path: str, port: int = 7860) -> None:
|
|
52
|
-
base = f"http://127.0.0.1:{port}"
|
|
53
|
-
|
|
54
|
-
# Step 1: Submit generation request
|
|
55
|
-
# Args: text, temperature, top_p, repetition_penalty, chunk_size, streaming
|
|
56
|
-
payload = json.dumps({
|
|
57
|
-
"data": [text, 0.0, 0.95, 1.2, 1, False]
|
|
58
|
-
}).encode()
|
|
59
|
-
|
|
60
|
-
event_id = submit_request(base, payload)
|
|
61
|
-
|
|
62
|
-
# Step 2: Poll SSE stream for audio file URL
|
|
63
|
-
audio_url = poll_for_result(base, event_id)
|
|
64
|
-
|
|
65
|
-
# Step 3: Download the audio file
|
|
66
|
-
download_file(audio_url, output_path)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
def submit_request(base: str, payload: bytes) -> str:
|
|
70
|
-
"""Submit generation request to Gradio API, return event_id."""
|
|
71
|
-
for api_base in ["/gradio_api/call", "/call"]:
|
|
72
|
-
url = f"{base}{api_base}/generate_speech"
|
|
73
|
-
req = urllib.request.Request(
|
|
74
|
-
url,
|
|
75
|
-
data=payload,
|
|
76
|
-
headers={"Content-Type": "application/json"},
|
|
77
|
-
)
|
|
78
|
-
try:
|
|
79
|
-
with urllib.request.urlopen(req, timeout=30) as resp:
|
|
80
|
-
return json.loads(resp.read())["event_id"]
|
|
81
|
-
except urllib.error.URLError:
|
|
82
|
-
continue
|
|
83
|
-
|
|
84
|
-
raise RuntimeError("Could not reach Soprano WebUI API")
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def poll_for_result(base: str, event_id: str) -> str:
|
|
88
|
-
"""Poll SSE endpoint until audio file URL is returned."""
|
|
89
|
-
for api_base in ["/gradio_api/call", "/call"]:
|
|
90
|
-
url = f"{base}{api_base}/generate_speech/{event_id}"
|
|
91
|
-
req = urllib.request.Request(url)
|
|
92
|
-
try:
|
|
93
|
-
with urllib.request.urlopen(req, timeout=120) as resp:
|
|
94
|
-
for raw_line in resp:
|
|
95
|
-
line = raw_line.decode("utf-8", errors="replace").strip()
|
|
96
|
-
if not line.startswith("data: "):
|
|
97
|
-
continue
|
|
98
|
-
try:
|
|
99
|
-
parsed = json.loads(line[6:])
|
|
100
|
-
except json.JSONDecodeError:
|
|
101
|
-
continue
|
|
102
|
-
# Response format: [{"path": "...", "url": "...", ...}, "status string"]
|
|
103
|
-
if isinstance(parsed, list) and len(parsed) >= 1:
|
|
104
|
-
audio = parsed[0]
|
|
105
|
-
if isinstance(audio, dict) and "url" in audio:
|
|
106
|
-
return audio["url"]
|
|
107
|
-
break
|
|
108
|
-
except urllib.error.URLError:
|
|
109
|
-
continue
|
|
110
|
-
|
|
111
|
-
raise RuntimeError("No audio URL in Soprano response")
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
def download_file(url: str, output_path: str) -> None:
|
|
115
|
-
"""Download audio file from Gradio file server."""
|
|
116
|
-
req = urllib.request.Request(url)
|
|
117
|
-
with urllib.request.urlopen(req, timeout=30) as resp:
|
|
118
|
-
with open(output_path, "wb") as f:
|
|
119
|
-
while True:
|
|
120
|
-
chunk = resp.read(8192)
|
|
121
|
-
if not chunk:
|
|
122
|
-
break
|
|
123
|
-
f.write(chunk)
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if __name__ == "__main__":
|
|
127
|
-
if len(sys.argv) < 3:
|
|
128
|
-
print(f"Usage: {sys.argv[0]} \"text\" output.wav [port]", file=sys.stderr)
|
|
129
|
-
sys.exit(1)
|
|
130
|
-
|
|
131
|
-
text = sys.argv[1]
|
|
132
|
-
output = sys.argv[2]
|
|
133
|
-
port = int(sys.argv[3]) if len(sys.argv) > 3 else 7860
|
|
134
|
-
|
|
135
|
-
try:
|
|
136
|
-
synth(text, output, port)
|
|
137
|
-
except Exception as e:
|
|
138
|
-
print(f"Error: {e}", file=sys.stderr)
|
|
139
|
-
sys.exit(1)
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
#
|
|
3
|
+
# File: .claude/hooks/soprano-gradio-synth.py
|
|
4
|
+
#
|
|
5
|
+
# AgentVibes - Finally, your AI Agents can Talk Back!
|
|
6
|
+
# Website: https://agentvibes.org
|
|
7
|
+
# Repository: https://github.com/paulpreibisch/AgentVibes
|
|
8
|
+
#
|
|
9
|
+
# Co-created by Paul Preibisch with Claude AI
|
|
10
|
+
# Copyright (c) 2025 Paul Preibisch
|
|
11
|
+
#
|
|
12
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
# you may not use this file except in compliance with the License.
|
|
14
|
+
# You may obtain a copy of the License at
|
|
15
|
+
#
|
|
16
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
#
|
|
18
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
# See the License for the specific language governing permissions and
|
|
22
|
+
# limitations under the License.
|
|
23
|
+
#
|
|
24
|
+
# ---
|
|
25
|
+
#
|
|
26
|
+
# Soprano Gradio WebUI synthesizer helper.
|
|
27
|
+
# Calls the Soprano WebUI's Gradio API and saves the result as a WAV file.
|
|
28
|
+
# Uses only Python stdlib (json, sys, urllib) — no extra dependencies.
|
|
29
|
+
#
|
|
30
|
+
# Usage: python3 soprano-gradio-synth.py "text to speak" output.wav [port]
|
|
31
|
+
#
|
|
32
|
+
"""
|
|
33
|
+
Soprano Gradio WebUI synthesizer helper for AgentVibes.
|
|
34
|
+
|
|
35
|
+
Calls the Soprano WebUI's Gradio API via the Server-Sent Events (SSE) protocol
|
|
36
|
+
and downloads the generated audio as a WAV file.
|
|
37
|
+
|
|
38
|
+
Flow:
|
|
39
|
+
1. Submit generation request → get event_id
|
|
40
|
+
2. Poll SSE stream for audio file URL
|
|
41
|
+
3. Download WAV file to output path
|
|
42
|
+
|
|
43
|
+
See: https://github.com/ekwek1/soprano
|
|
44
|
+
"""
|
|
45
|
+
import json
|
|
46
|
+
import sys
|
|
47
|
+
import urllib.request
|
|
48
|
+
import urllib.error
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def synth(text: str, output_path: str, port: int = 7860) -> None:
|
|
52
|
+
base = f"http://127.0.0.1:{port}"
|
|
53
|
+
|
|
54
|
+
# Step 1: Submit generation request
|
|
55
|
+
# Args: text, temperature, top_p, repetition_penalty, chunk_size, streaming
|
|
56
|
+
payload = json.dumps({
|
|
57
|
+
"data": [text, 0.0, 0.95, 1.2, 1, False]
|
|
58
|
+
}).encode()
|
|
59
|
+
|
|
60
|
+
event_id = submit_request(base, payload)
|
|
61
|
+
|
|
62
|
+
# Step 2: Poll SSE stream for audio file URL
|
|
63
|
+
audio_url = poll_for_result(base, event_id)
|
|
64
|
+
|
|
65
|
+
# Step 3: Download the audio file
|
|
66
|
+
download_file(audio_url, output_path)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def submit_request(base: str, payload: bytes) -> str:
|
|
70
|
+
"""Submit generation request to Gradio API, return event_id."""
|
|
71
|
+
for api_base in ["/gradio_api/call", "/call"]:
|
|
72
|
+
url = f"{base}{api_base}/generate_speech"
|
|
73
|
+
req = urllib.request.Request(
|
|
74
|
+
url,
|
|
75
|
+
data=payload,
|
|
76
|
+
headers={"Content-Type": "application/json"},
|
|
77
|
+
)
|
|
78
|
+
try:
|
|
79
|
+
with urllib.request.urlopen(req, timeout=30) as resp:
|
|
80
|
+
return json.loads(resp.read())["event_id"]
|
|
81
|
+
except urllib.error.URLError:
|
|
82
|
+
continue
|
|
83
|
+
|
|
84
|
+
raise RuntimeError("Could not reach Soprano WebUI API")
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def poll_for_result(base: str, event_id: str) -> str:
|
|
88
|
+
"""Poll SSE endpoint until audio file URL is returned."""
|
|
89
|
+
for api_base in ["/gradio_api/call", "/call"]:
|
|
90
|
+
url = f"{base}{api_base}/generate_speech/{event_id}"
|
|
91
|
+
req = urllib.request.Request(url)
|
|
92
|
+
try:
|
|
93
|
+
with urllib.request.urlopen(req, timeout=120) as resp:
|
|
94
|
+
for raw_line in resp:
|
|
95
|
+
line = raw_line.decode("utf-8", errors="replace").strip()
|
|
96
|
+
if not line.startswith("data: "):
|
|
97
|
+
continue
|
|
98
|
+
try:
|
|
99
|
+
parsed = json.loads(line[6:])
|
|
100
|
+
except json.JSONDecodeError:
|
|
101
|
+
continue
|
|
102
|
+
# Response format: [{"path": "...", "url": "...", ...}, "status string"]
|
|
103
|
+
if isinstance(parsed, list) and len(parsed) >= 1:
|
|
104
|
+
audio = parsed[0]
|
|
105
|
+
if isinstance(audio, dict) and "url" in audio:
|
|
106
|
+
return audio["url"]
|
|
107
|
+
break
|
|
108
|
+
except urllib.error.URLError:
|
|
109
|
+
continue
|
|
110
|
+
|
|
111
|
+
raise RuntimeError("No audio URL in Soprano response")
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def download_file(url: str, output_path: str) -> None:
|
|
115
|
+
"""Download audio file from Gradio file server."""
|
|
116
|
+
req = urllib.request.Request(url)
|
|
117
|
+
with urllib.request.urlopen(req, timeout=30) as resp:
|
|
118
|
+
with open(output_path, "wb") as f:
|
|
119
|
+
while True:
|
|
120
|
+
chunk = resp.read(8192)
|
|
121
|
+
if not chunk:
|
|
122
|
+
break
|
|
123
|
+
f.write(chunk)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
if __name__ == "__main__":
|
|
127
|
+
if len(sys.argv) < 3:
|
|
128
|
+
print(f"Usage: {sys.argv[0]} \"text\" output.wav [port]", file=sys.stderr)
|
|
129
|
+
sys.exit(1)
|
|
130
|
+
|
|
131
|
+
text = sys.argv[1]
|
|
132
|
+
output = sys.argv[2]
|
|
133
|
+
port = int(sys.argv[3]) if len(sys.argv) > 3 else 7860
|
|
134
|
+
|
|
135
|
+
try:
|
|
136
|
+
synth(text, output, port)
|
|
137
|
+
except Exception as e:
|
|
138
|
+
print(f"Error: {e}", file=sys.stderr)
|
|
139
|
+
sys.exit(1)
|