dsh-LocalAIService: Using Local AI in DSH

Introduction

A plugin for DSH that leverages local AI: reading replies aloud, speaking via microphone, converting audio and video to text, and providing the Agent with local voice and media processing capabilities. All processing happens locally — no internet connection is required, and no extra API call costs are incurred.

What Is This

dsh-LocalAIService is a plugin that provides local AI capabilities to DSH. It is maintained by INFIcer. It calls local AI services via HTTP. It does not take over the inference process; instead, it provides voice, media processing, and status query capabilities to the user interface and the Agent.

Core Features

Read Aloud

There is a speaker button next to each completed reply. Click once to start reading aloud, click again to stop. Long content is played as it is generated — you don’t have to wait for the entire text to be ready. Re-reading the same content will reuse the previously generated audio.

  • Hover over the action bar below the reply and click the speaker button.
  • During preparation, the button shows a spinner; while playing, it shows a pause icon.
  • When reading in segments, the button displays progress (e.g., 2/5). Switching messages or clicking again will stop playback.

Voice Input

The microphone button on the right side of the input box allows recording. After finishing, choose “Transcribe to Text,” “Attach as File,” or “Cancel.” Transcribed text is inserted at the cursor position and can be further edited.

  • Click the microphone icon on the right side of the input box to start recording; click again to stop.
  • In the floating panel, select:
  • Transcribe to Text: Convert the recording to text and insert it into the input box.
  • Attach as File: Add the recording as a file attachment to the input box (the kernel’s draft attachment card, which can be sent directly along with text).
  • Cancel: Discard this recording.
  • Maximum recording duration is 5 minutes; maximum file size is 25 MB. If multiple microphones are available, you can specify which one to use in the Settings page; by default it follows the system setting.

Auto Read-Aloud

The toggle on the left side of the input box applies per conversation. When enabled, newly received replies are automatically read aloud. The “Auto read-aloud for new conversations” option in Settings determines the initial state for new conversations.

Local AI Status

A small capsule indicator at the bottom-left of the input box displays GPU memory usage and task count. When no tasks are running, it shows “Idle.”

  • Click to expand details above the capsule: GPU and VRAM info, loaded models, queued and running tasks, service version, and uptime.
  • In the panel, you can “Open Management UI,” “Release VRAM,” or refresh. Release results are displayed directly in the panel. Click outside the panel or press Esc to close.
  • When the local AI service is not running, the capsule appears grayed out.

Release VRAM

When you need to free up GPU resources for other programs, click “Release VRAM.” The plugin instructs the local AI to unload models that currently have no active tasks. Tasks in progress are skipped, and the number of skipped items is included in the result. Unloading does not affect subsequent usage — models are reloaded on demand at the next call.

Select & Read / Translate

Select text within a reply, and a floating menu appears with “Read Aloud” and “Translate.”

  • Read Aloud only reads the selected portion.
  • Translation results appear in a small panel where you can copy or dismiss.
  • Click outside the panel or press Esc to close. Both buttons are disabled when the local AI service is not running.

Local Image Recognition

The “Local Image Recognition” button next to the input box lets you select images. The content is recognized locally, and the description is inserted sequentially into the input box. Images are not added to the draft or uploaded with the message — the model only sees the text description (saving tokens). This feature can be disabled in Settings. The recognition prompt has four levels and is editable, defaulting to “Detailed.”

  • Click the image button on the right side of the input box and select one or more images.
  • Images are recognized sequentially on the local machine. Upon completion, “[Image: filename] + description” entries are inserted into the input box in order.
  • If the local AI is offline or recognition fails, a brief notice is shown and the input box remains unchanged.
  • In the “Image Recognition” section of Settings, you can disable this button or adjust the four prompt levels (Brief, Standard, Detailed, Text Only) and the default level. The prompt for conversation-based image recognition (this button) is configured separately.

Agent Tools

The plugin provides 9 tools to the Agent, covering text-to-speech, speech recognition, translation, vocal separation, video keyframe extraction, image understanding, media info retrieval, task queries, and status queries.

Tool Purpose
fish_tts Convert text to speech, up to 20 items per call
fish_asr Transcribe local audio or video to text, with optional per-segment timestamps
fish_translate Batch-translate text; target language can be auto-selected
fish_separate Separate audio or video into vocal, drums, bass, and other stems
fish_vision_frames Extract keyframes from a local video and generate summaries
fish_describe_image Describe local image content (four levels, default Detailed), rate the image, or OCR text in the image
fish_media_probe Read duration and audio/video parameters of a local media file
fish_job Query, cancel, or wait for a local task
fish_service_status Check local AI status and capabilities

Tools only return local file paths, elapsed time, and similar metadata — not the file content itself. On failure, a ready-to-display message is provided.

fish_describe_image is only valuable when the model cannot see the image: when an image is sent as an attachment in the conversation, the model sees it directly and will not call this tool for redundant recognition (which would be slower and the description would still be less detailed than the original). It is intended for cases where only a local file path is available, or when rating and character-by-character OCR are needed.

Settings Page

Under “Settings → Plugins → Local AI,” you can view status and capabilities, adjust read-aloud and voice input preferences, inspect and manage the cache, and read runtime logs.

  • Changes take effect immediately after clicking “Save Settings” — no restart required.
  • “Test Connection” checks whether the local AI service is reachable. Immediately after a service starts, some capabilities may not be ready yet; use this to refresh.
  • The Read-Aloud section lets you open the voice folder. The Translation section lets you set the first and second language; when no target language is specified, it auto-selects based on the source language.
  • The Cache section shows usage and reuse statistics. You can also clear the read-aloud cache or remove expired files.
  • The “Status” card includes a “Release VRAM” button. It only unloads idle models, and the result is displayed at the top of the page.

Installation & Activation

Prerequisites: A compatible local AI service must already be installed and running on your machine, and the required models must have been downloaded for first-time use. If you don’t have a server yet, you can use “One-Click Deploy” to set it up (see the next section). The plugin still only calls the local AI via HTTP and does not take over its inference.

Please install the plugin via the command line (manually editing configuration is prone to missing dependencies). Replace the path with the actual location on your machine:

dsh plugin --profile desktop add E:\dsh-LocalAIService

After installation, restart DSH for the plugin to load. The installation process does not start or restart the local AI service.

One-Click Deploy (Windows x64)

When the plugin cannot detect a local service, you can use the plugin to download the server to your machine, create a virtual environment, start the service, download models, and finally point the plugin to the new service. The installer uses port 7880 exclusively. It does not install drivers, does not install a system-level Python, and does not register Windows services.

Size & Time (First-time install, measured/estimated)

Component Size Time
Server code ~3.4 MB (incl. .git; zip ~1.2 MB) 10–60 seconds
Virtual env + core deps ~100–600 MB (measured 96.5 MB) 2–5 minutes
Engine deps (torch cu130, etc.) ~6.5 GB 10–30 minutes; can be skipped with skipEngine at install time
Models: default selection ~9.1 GB 10–40 minutes, depending on network speed
Models: full set ~17.7 GB Longer

The default installation directory is %LOCALAPPDATA%\localai-service; a custom path can be specified at invocation time. Drive root, system directories, network paths, and junctions are not allowed. Installation logs are at %USERPROFILE%\.dsh\fish-service-install.log (follows DSH_HOME if customized). Service logs are at <install_dir>\logs\service.*.log.

What It Can Do

  • Pre-flight checks: Windows version/architecture, disk free space (code + venv + selected models + 10%), NVIDIA GPU and driver version (compare only), port 7880 availability, existing install markers, git, Python 3.11–3.13, network (GitHub/PyPI/PyTorch, 5-second timeout), ffmpeg, and directory write permissions.
  • Installation: git clone --depth 1 to fetch code (falls back to codeload zip on failure) → python -m venv → core dependencies → optional engine dependencies (pinned --index-url .../cu130) → start start_ai_service.ps1 → /health returns HTTP 200 → /capabilities verifies api_version=1 → write plugin config and install status.
  • Models: Calls the server’s /admin/models and /admin/models/download endpoints. Downloads proceed serially in order of “required → recommended → optional” with progress polling. Missing models do not cause the installation to fail, but incomplete items are listed honestly.
  • Adoption: When an existing localai-service is detected on port 7880, it adopts read-only — no reinstall, no directory move, no service restart.
  • Cancellation: Kills the process tree and rolls back paths created during this run. models/voices/data/outputs/logs/config.json are always preserved.

What It Cannot Do

  • Does not install CUDA drivers, does not install a system-level Python, does not register Windows services or scheduled tasks (auto-start on boot is not yet implemented).
  • Does not support uv auto-bootstrapping, offline packages, manifest/SHA256 verification, upgrade, or uninstall (future versions). The server repository has no release/tag; the main branch is installed.
  • Only supports Windows 10 19045+ / Windows 11 x64. Port 7880 is fixed; no automatic port switching.
  • Does not modify existing non-empty directories. If the target directory contains files but no install marker from this plugin, the operation is refused to avoid overwriting user code.

Troubleshooting Failures

  1. Call GET /dsh-fish-service/install/status to check error.hint, the failed step, and steps[].
  2. Call GET /dsh-fish-service/install/logs?lines=200 for full command output. Git clone failures are usually network/proxy issues; pip failures are usually PyPI mirror issues; torch failures — check disk space and the PyTorch index.
  3. For startup failures, check <install_dir>\logs\service.err.log. Common causes: port 7880 in use, special characters in the path, or incomplete dependencies.
  4. Before reinstalling, delete <install_dir>\.dsh-fish-service-install.json and clear the code directory (models/voices/data can be kept).
  5. If the previous install was interrupted by a DSH restart, the status in the state file may be installing. Clean up per step 4 and retry.

API Examples

# Preflight (read-only; installDir is optional)
curl.exe -s -X POST http://127.0.0.1:14792/dsh-fish-service/install/preflight -H "content-type: application/json" -d '{}'
# Start installation (returns taskId asynchronously; skipEngine defaults to false, client can pass true as needed)
curl.exe -s -X POST http://127.0.0.1:14792/dsh-fish-service/install/start -H "content-type: application/json" -d '{"skipEngine":true,"models":["tts","asr","speaker","vad","separate"]}'
# Poll status / cancel / logs / adopt
curl.exe -s http://127.0.0.1:14792/dsh-fish-service/install/status
curl.exe -s -X POST http://127.0.0.1:14792/dsh-fish-service/install/cancel
curl.exe -s "http://127.0.0.1:14792/dsh-fish-service/install/logs?lines=200"
curl.exe -s -X POST http://127.0.0.1:14792/dsh-fish-service/install/adopt

The actual DSH Web port depends on the runtime (14792 above is just an example).

Use Cases & Notes

This plugin is suitable for users who need to process voice, video, and images locally while avoiding internet dependency and extra API call costs. The plugin runs with the permissions of the current DSH process. Review the source code and license before installation.

Known Limitations

  • One-Click Deploy only covers “fresh install + adoption.” Upgrade, uninstall, auto-start on boot, and offline packages are not yet implemented.
  • The install/cancel/model-download operations in One-Click Deploy are background tasks; only one is allowed at a time. Cancellation rolls back files created during this run (user data is excluded).
  • The installer uses port 7880 exclusively. If the port is occupied by another program, a warning is shown but the port is not changed automatically.
  • Do not run the installation via the command line simultaneously. If the install directory already contains this plugin’s marker, the operation will be refused.
  • Direct analysis of network videos is not supported; save the video locally first.
  • Processing long videos takes considerable time, with no progress indicator during the process.
  • Local image recognition typically takes a few seconds (longer on first use while the model loads). During recognition, the button shows a spinner and cannot be clicked repeatedly. On failure, the input box remains unchanged and a brief notice is shown.
  • Local image recognition only provides the model with a text description; the model does not see the original image. If you need the model to examine details, send the image as an attachment instead (attachments are shown directly to the model).
  • The capability list is based on the most recent probe. Immediately after the local AI starts, some capabilities may appear unavailable; click “Test Connection” to refresh.
  • The plugin does not automatically release VRAM: when VRAM is insufficient, it only suggests closing VRAM-consuming programs or manually clicking “Release VRAM” in the status overlay / Settings page. Manual release only unloads models with no active tasks; running tasks are skipped.

Summary

dsh-LocalAIService provides DSH with local voice, media processing, and status query capabilities. It supports read-aloud, voice input, auto read-aloud, local image recognition, and select-to-read/translate, and provides 9 tools to the Agent. With command-line installation and One-Click Deploy, you can quickly set up a local AI environment on Windows. For more information, see the plugin directory page and the GitHub repository.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye