ttstoy: remove server start/install commands now handled by systemd

Drop the dectalkstart, dectalkinstall, dectalkautotoggle, morshustart, and
voxstart commands along with the orphaned _start/_stop/_install helper methods
and the dectalk mode-switch auto-start path. The three TTS servers run as
independent systemd services; the stop and status commands now point at
systemctl.
This commit is contained in:
2026-09-14 14:43:16 -05:00
parent 9ca1511f82
commit 5545564e3b
+7 -237
View File
@@ -498,133 +498,6 @@ class TtsToy(Cog):
"""Get DECTalk API URL.""" """Get DECTalk API URL."""
return await self.config.dectalk_api_url() return await self.config.dectalk_api_url()
async def _install_dectalk_server(self) -> bool:
"""Install DECTalk server dependencies."""
try:
if not self.dectalk_dir.exists():
log.error(f"DECTalk server directory not found: {self.dectalk_dir}")
return False
# Run npm install
result = await asyncio.to_thread(
subprocess.run,
["npm", "install"],
cwd=str(self.dectalk_dir),
capture_output=True,
text=True,
timeout=300
)
if result.returncode != 0:
log.error(f"npm install failed: {result.stderr}")
return False
log.info("DECTalk server installed successfully")
return True
except Exception as e:
log.exception(f"Failed to install DECTalk server: {e}")
return False
async def _start_dectalk_server(self) -> bool:
"""Check whether the independent DECTalk service is reachable.
The DECTalk server now runs as a standalone systemd service
(dectalk-tts-server) and is no longer spawned by the bot. This method
only confirms the service is up on its fixed port.
"""
try:
def _check():
try:
r = requests.get(
f"http://127.0.0.1:{self.dectalk_port}/health", timeout=5
)
return r.status_code == 200
except Exception:
return False
reachable = await asyncio.to_thread(_check)
if reachable:
log.info(f"DECTalk service reachable on port {self.dectalk_port}")
else:
log.warning(
f"DECTalk service not reachable on port {self.dectalk_port}. "
"Ensure the dectalk-tts-server systemd service is running."
)
return reachable
except Exception as e:
log.exception(f"Failed to check DECTalk service: {e}")
return False
async def _stop_dectalk_server(self):
"""No-op. The DECTalk service is managed by systemd, not the bot."""
return
async def _start_morshu_server(self) -> tuple:
"""Check whether the independent Morshu service is reachable.
The Morshu server now runs as a standalone systemd service
(morshu-tts-server) and is no longer spawned by the bot. Returns
(reachable, error_msg).
"""
try:
def _check():
try:
r = requests.get(
f"http://127.0.0.1:{self.morshu_port}/health", timeout=5
)
return r.status_code == 200
except Exception:
return False
reachable = await asyncio.to_thread(_check)
if reachable:
log.info(f"Morshu service reachable on port {self.morshu_port}")
return True, None
return False, (
f"Morshu service not reachable on port {self.morshu_port}. "
"Ensure the morshu-tts-server systemd service is running."
)
except Exception as e:
log.exception(f"Failed to check Morshu service: {e}")
return False, str(e)
async def _stop_morshu_server(self):
"""No-op. The Morshu service is managed by systemd, not the bot."""
return
async def _start_vox_server(self) -> tuple:
"""Check whether the independent VOX service is reachable.
The VOX server now runs as a standalone systemd service
(vox-tts-server) and is no longer spawned by the bot. Returns
(reachable, error_msg).
"""
try:
def _check():
try:
r = requests.get(
f"http://127.0.0.1:{self.vox_port}/health", timeout=5
)
return r.status_code == 200
except Exception:
return False
reachable = await asyncio.to_thread(_check)
if reachable:
log.info(f"VOX service reachable on port {self.vox_port}")
return True, None
return False, (
f"VOX service not reachable on port {self.vox_port}. "
"Ensure the vox-tts-server systemd service is running."
)
except Exception as e:
log.exception(f"Failed to check VOX service: {e}")
return False, str(e)
async def _stop_vox_server(self):
"""No-op. The VOX service is managed by systemd, not the bot."""
return
async def _get_effective_minimax_voice(self, user: discord.abc.User) -> str: async def _get_effective_minimax_voice(self, user: discord.abc.User) -> str:
mode = await self._get_tts_mode() mode = await self._get_tts_mode()
@@ -1431,27 +1304,15 @@ class TtsToy(Cog):
) )
elif mode == "dectalk": elif mode == "dectalk":
dectalk_url = await self._get_dectalk_api_url() dectalk_url = await self._get_dectalk_api_url()
auto_start = await self.config.dectalk_auto_start()
msg = f"✅ TTS mode set to {mode_emoji} **DECTALK**\n" msg = f"✅ TTS mode set to {mode_emoji} **DECTALK**\n"
msg += f"Using DECTalk API at: `{dectalk_url}`\n" msg += f"Using DECTalk API at: `{dectalk_url}`\n"
msg += (
if auto_start: "The DECTalk server runs as an independent systemd service "
msg += "🚀 Auto-starting DECTalk server..." "(dectalk-tts-server). Make sure it is running: "
await ctx.send(msg) "`sudo systemctl status dectalk-tts-server`"
)
if await self._start_dectalk_server(): await ctx.send(msg)
await ctx.send("✅ DECTalk server started successfully!")
else:
await ctx.send(
"❌ Failed to start DECTalk server.\n"
f"Try manually: `{ctx.clean_prefix}ttstoy dectalkstart`\n"
f"Or install: `{ctx.clean_prefix}ttstoy dectalkinstall`"
)
else:
msg += f"Make sure your DECTalk server is running!\n"
msg += f"Or enable auto-start: `{ctx.clean_prefix}ttstoy dectalkautotoggle`"
await ctx.send(msg)
else: else:
await ctx.send( await ctx.send(
f"✅ TTS mode set to {mode_emoji} **MINIMAX**\n" f"✅ TTS mode set to {mode_emoji} **MINIMAX**\n"
@@ -2070,47 +1931,6 @@ class TtsToy(Cog):
await self.config.dectalk_api_url.set(url) await self.config.dectalk_api_url.set(url)
await ctx.send(f"✅ DECTalk API URL set to: `{url}`") await ctx.send(f"✅ DECTalk API URL set to: `{url}`")
@ttstoy_group.command(name="dectalkinstall")
@commands.is_owner()
async def dectalk_install(self, ctx: commands.Context):
"""Install the built-in DECTalk server."""
await ctx.send("📦 Installing DECTalk server (this may take a minute)...")
success = await self._install_dectalk_server()
if success:
await ctx.send(
"✅ DECTalk server installed successfully!\n"
f"Start it with: `{ctx.clean_prefix}ttstoy dectalkstart`\n"
f"Or enable auto-start: `{ctx.clean_prefix}ttstoy dectalkautotoggle`"
)
else:
await ctx.send(
"❌ Failed to install DECTalk server.\n"
"Make sure Node.js and npm are installed.\n"
"Check the bot logs for details."
)
@ttstoy_group.command(name="dectalkstart")
@commands.is_owner()
async def dectalk_start(self, ctx: commands.Context):
"""Start the built-in DECTalk server."""
await ctx.send("🚀 Starting DECTalk server...")
success = await self._start_dectalk_server()
if success:
await ctx.send(
f"✅ DECTalk server started on port {self.dectalk_port}!\n"
f"Switch to DECTalk mode: `{ctx.clean_prefix}ttstoy mode dectalk`"
)
else:
await ctx.send(
"❌ Failed to start DECTalk server.\n"
f"Try installing first: `{ctx.clean_prefix}ttstoy dectalkinstall`\n"
"Check the bot logs for details."
)
@ttstoy_group.command(name="dectalkstop") @ttstoy_group.command(name="dectalkstop")
@commands.is_owner() @commands.is_owner()
async def dectalk_stop(self, ctx: commands.Context): async def dectalk_stop(self, ctx: commands.Context):
@@ -2160,39 +1980,6 @@ class TtsToy(Cog):
await ctx.send("\n".join(lines)) await ctx.send("\n".join(lines))
@ttstoy_group.command(name="dectalkautotoggle")
@commands.is_owner()
async def dectalk_auto_toggle(self, ctx: commands.Context):
"""Toggle auto-start for built-in DECTalk server."""
current = await self.config.dectalk_auto_start()
new_state = not current
await self.config.dectalk_auto_start.set(new_state)
status = "enabled" if new_state else "disabled"
await ctx.send(f"✅ DECTalk auto-start {status}")
if new_state:
await ctx.send("DECTalk server will start automatically when switching to DECTalk mode.")
else:
await ctx.send(f"You'll need to manually start DECTalk with `{ctx.clean_prefix}ttstoy dectalkstart`")
@ttstoy_group.command(name="morshustart")
@commands.is_owner()
async def morshu_start(self, ctx: commands.Context):
"""Start the built-in Morshu TTS server."""
await ctx.send("🚀 Starting Morshu server...")
success, error = await self._start_morshu_server()
if success:
await ctx.send(
f"✅ Morshu server started on port {self.morshu_port}!\n"
f"Switch to Morshu mode: `{ctx.clean_prefix}ttstoy mode morshu`"
)
else:
err_msg = (error or "Unknown error")[:1500]
await ctx.send(f"❌ Failed to start Morshu server:\n```\n{err_msg}\n```")
@ttstoy_group.command(name="morshustop") @ttstoy_group.command(name="morshustop")
@commands.is_owner() @commands.is_owner()
async def morshu_stop(self, ctx: commands.Context): async def morshu_stop(self, ctx: commands.Context):
@@ -2228,23 +2015,6 @@ class TtsToy(Cog):
await ctx.send("\n".join(lines)) await ctx.send("\n".join(lines))
@ttstoy_group.command(name="voxstart")
@commands.is_owner()
async def vox_start(self, ctx: commands.Context):
"""Start the built-in VOX TTS server."""
await ctx.send("🚀 Starting VOX server...")
success, error = await self._start_vox_server()
if success:
await ctx.send(
f"✅ VOX server started on port {self.vox_port}!\n"
f"Switch to VOX mode: `{ctx.clean_prefix}ttstoy mode vox`"
)
else:
err_msg = (error or "Unknown error")[:1500]
await ctx.send(f"❌ Failed to start VOX server:\n```\n{err_msg}\n```")
@ttstoy_group.command(name="voxstop") @ttstoy_group.command(name="voxstop")
@commands.is_owner() @commands.is_owner()
async def vox_stop(self, ctx: commands.Context): async def vox_stop(self, ctx: commands.Context):