Skip to content

[Bug]: The sherpa-onnx-tts script in the bin/ folder of the skill uses CommonJS syntax (fails to run) #31956

@cbuchner1

Description

@cbuchner1

Bug type

Behavior bug (incorrect output/state without crash)

Summary

I get an error testing the sherpa-onnx-ts script using node.js from the command line, which is fixable by switching the import statements at the top of the file to ESM syntax:

import fs from "node:fs";
import path from "node:path";
import { spawnSync } from "node:child_process";

Steps to reproduce

Running the sherpa-onnx-tts script within the bin subdir of the respective skill reproduces the problem.

Expected behavior

I expect a WAV file to be created like in the following (after applying the proposed fix)

openclaw@openClaw-VMWareFusion25H2:~$ ~/.npm-global/lib/node_modules/openclaw/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts -o ./tts.wav "Hello from local TTS."
onnxruntime cpuid_info warning: Unknown CPU vendor. cpuinfo_vendor value: 0
/k2-fsa/sherpa-onnx/sherpa-onnx/csrc/parse-options.cc:Read:373 /opt/sherpa-onnx/bin/sherpa-onnx-offline-tts --vits-model=/opt/piper-voices/vits-piper-de_DE-thorsten-high/de_DE-thorsten-high.onnx --vits-tokens=/opt/piper-voices/vits-piper-de_DE-thorsten-high/tokens.txt --vits-data-dir=/opt/piper-voices/vits-piper-de_DE-thorsten-high/espeak-ng-data --output-filename=/home/openclaw/tts.wav 'Hello from local TTS.' 

sample=38400, progress=1.000000
Number of threads: 1
Elapsed seconds: 0.974 s
Audio duration: 1.741 s
Real-time factor (RTF): 0.974/1.741 = 0.559
The text is: Hello from local TTS.. Speaker ID: 0
Saved to /home/openclaw/tts.wav successfully!

Actual behavior

The following error is thrown instead.

openclaw@openClaw-VMWareFusion25H2:~$ ~/.npm-global/lib/node_modules/openclaw/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts -o ./tts.wav "Hello from local TTS."
file:///home/openclaw/.npm-global/lib/node_modules/openclaw/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts:3
const fs = require("node:fs");
           ^

ReferenceError: require is not defined in ES module scope, you can use import instead
    at file:///home/openclaw/.npm-global/lib/node_modules/openclaw/skills/sherpa-onnx-tts/bin/sherpa-onnx-tts:3:12
    at ModuleJob.run (node:internal/modules/esm/module_job:343:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:665:26)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

Node.js v22.22.0

OpenClaw version

2026.2.26

Operating system

Ubuntu 25.10 ARM64

Install method

npm

Logs, screenshots, and evidence

Impact and severity

Affected: Users wanting to use the skill to perform local TTS.
Severity: built-in skill not operating
Frequency: always
Consequence: no local TTS option available.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug:behaviorIncorrect behavior without a crash

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions