dsh-tts: Turn Text into Speech, Keep the Engine Outside the Plugin

Introduction

In the development scenarios of DSH Host, Text-to-Speech (TTS) typically requires binding to specific engines. The dsh-tts plugin decouples this logic, focusing on “synthesis” and “timestamp” calculation, while leaving the audio engine (such as Microsoft Edge or local command-line tools) as an external dependency. It does not decide which audio sounds better or how to concatenate clips; it simply produces files and numbers for the caller to process.

Core Features

The plugin provides three main tools, covering the entire workflow from synthesis to inspection:

  1. tts_speak: Supports both speak (single text segment) and dialogue (multi-speaker script) modes. speak outputs audio and a word-by-word timestamp sidecar file; dialogue generates a manifest and global word-level timestamps.
  2. tts_setup: Provides three actions: status, voices, and check. Used to verify engine availability, enumerate voice lists, and synthesize a self-test sentence.
  3. tts_guide: Provides four actions: overview, tool, action, and rules. Used to read complete reference documentation, including parameter descriptions, measured data, and edge cases.

Providers and Configuration

The plugin supports two providers, selected via configuration:

  1. edge (default): Based on the Microsoft Edge Read Aloud endpoint. Requires no Key, relies on the network, and provides word-by-word timestamps (server-side WordBoundary). Local testing identified 322 voices, including 14 starting with Chinese (zh).
  2. command: A local TTS command-line engine. Requires no network, and engine upgrades do not require modifying the plugin. Uses template placeholders to pass parameters, such as {out}, {text}, {timings}, etc.

command Configuration Example

command:
  path: 'C:/tools/piper/piper.exe'
  args: ['--model', 'C:/tools/piper/zh_CN-huayan-medium.onnx', '--output_file', '{out}']
  textMode: 'stdin'
  outFormat: 'wav'
  voices: ['zh_CN-huayan-medium']

Installation and Activation

Installation requires no build step; it can be mounted directly in the profile using link:.

- insert:
    - id: dsh-tts
      name: 'dsh-tts'
      config: { provider: null, outDir: null, ffprobePath: null, edge: { voice: null }, command: null }

By default, the edge provider is ready to use out of the box. If no local engine is configured, tts_setup will report this truthfully.

Typical Usage

Run src/bin/tts.mjs using Node.js:

  1. Check environment and ffprobe:
node src/bin/tts.mjs doctor
  1. View Chinese voice list:
node src/bin/tts.mjs voices --locale zh
  1. Synthesize a text segment:
node src/bin/tts.mjs say "text to speak" --out a.mp3
  1. Check synthesis quality (including trailing silence):
node src/bin/tts.mjs check
  1. Synthesize multi-speaker dialogue script:
node src/bin/tts.mjs dialogue --script s.txt --voices host-a=...,host-b=...
  1. View rules documentation:
node src/bin/tts.mjs rules

Output and Contract

A synthesis operation generates two files: an audio file and a sidecar file with the same name (.words.json). The words array contains word-by-word text and start/end times, which can be directly read by downstream subtitle workflows (such as video_narrate).

In dialogue mode, in addition to the aforementioned sidecar file, a dialogue.manifest (containing clips and verification) and dialogue.words.json are also generated. verification is used to check whether audio clips fall within file boundaries; its value is true (measured and within file), false (out of bounds), or null (not measured).

Notes

  1. Commercial Licensing: The commercial licensing for the edge provider is unspecified; it is recommended for use only in drafts and personal content. For commercial use, please switch to the command provider and use a locally hosted engine with explicit licensing.
  2. Local Engine Limitations: There is currently no ready-made solution for Chinese word-level timestamps in pure Node local engines; local engine speed is approximately 1.1x real-time, and Chinese synthesis requires assistance from Python-side toolkits.
  3. Integration Dependencies: The integration dependency of video_narrate on dsh-video-audio has not yet been rebuilt (as of 2026-10-04), so it currently cannot flow through the standard process.
羽毛球分组比赛记分
小程序二维码

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

Xiaoye