mcp-speechmatics-transcribe 0.1.13 → 0.1.15
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/.env.example +0 -1
- package/README.md +9 -10
- package/cli.js +0 -2
- package/modules/config.js +0 -2
- package/modules/options.js +0 -2
- package/modules/tools.js +1 -2
- package/modules/transcribe.js +4 -2
- package/package.json +1 -1
package/.env.example
CHANGED
|
@@ -11,7 +11,6 @@ SPEECHMATICS_LANGUAGE=pl
|
|
|
11
11
|
SPEECHMATICS_DIARIZATION=speaker
|
|
12
12
|
# Audio events are supported by enhanced/standard.
|
|
13
13
|
SPEECHMATICS_AUDIO_EVENTS=true
|
|
14
|
-
SPEECHMATICS_CONVERT_TO_MP3=false
|
|
15
14
|
# Upload and processing timeout, independent of recording duration.
|
|
16
15
|
SPEECHMATICS_TIMEOUT_SECONDS=900
|
|
17
16
|
# Shared MCP discovery cache lifetime in milliseconds; 0 disables caching.
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Turn local audio and video recordings into searchable transcripts, speaker-labeled
|
|
4
4
|
subtitles, and readable Markdown with Speechmatics. Use the CLI for individual
|
|
5
5
|
files or connect the MCP server to a compatible client.
|
|
6
|
-
Requires Node.js 22.12+.
|
|
6
|
+
Requires Node.js 22.12+. Files other than MP3, AAC, OGG, M4A, and FLAC require FFmpeg in PATH.
|
|
7
7
|
|
|
8
8
|
## Quick start
|
|
9
9
|
|
|
@@ -49,9 +49,15 @@ Allow enough tool time for uploads and processing; the API timeout defaults to
|
|
|
49
49
|
900 seconds.
|
|
50
50
|
|
|
51
51
|
The transcribe tool requires an absolute file path. Optional parameters are model,
|
|
52
|
-
language, disableDiarization, audioEvents,
|
|
52
|
+
language, disableDiarization, audioEvents, and timeoutSeconds.
|
|
53
53
|
Missing credentials are reported when the tool is called; tool discovery remains available.
|
|
54
54
|
|
|
55
|
+
MP3, AAC, OGG, M4A, and FLAC files are uploaded unchanged, based on their file
|
|
56
|
+
extension. Other files are prepared automatically: FFmpeg first tries to copy
|
|
57
|
+
the first audio stream into an MP3, then encodes it to MP3 if copying fails.
|
|
58
|
+
Prepared audio stays in the output folder. Missing FFmpeg, missing audio, and
|
|
59
|
+
conversion failures are reported before upload. FFprobe is not required.
|
|
60
|
+
|
|
55
61
|
## Configuration
|
|
56
62
|
|
|
57
63
|
The `token_status` tool checks all configured tokens through the EU1
|
|
@@ -79,7 +85,6 @@ Source installations otherwise load .env from the package directory.
|
|
|
79
85
|
| SPEECHMATICS_LANGUAGE | pl | Language code; use multi for multilingual models |
|
|
80
86
|
| SPEECHMATICS_DIARIZATION | speaker | Speaker attribution; MCP only exposes disabling it |
|
|
81
87
|
| SPEECHMATICS_AUDIO_EVENTS | true | Enable events for Standard and Enhanced |
|
|
82
|
-
| SPEECHMATICS_CONVERT_TO_MP3 | false | Convert non-MP3 input through FFmpeg |
|
|
83
88
|
| SPEECHMATICS_TIMEOUT_SECONDS | 900 | Upload and processing timeout in seconds |
|
|
84
89
|
|
|
85
90
|
Boolean environment variables accept true or false.
|
|
@@ -102,7 +107,7 @@ transcription/<input filename>/:
|
|
|
102
107
|
- Raw json-v2 transcript and segment JSON.
|
|
103
108
|
- WebVTT subtitles with voice spans such as <v.speaker S1>.
|
|
104
109
|
- Markdown with the filename, source folder, speaker labels, and paragraph start times.
|
|
105
|
-
- An MP3
|
|
110
|
+
- An automatically prepared MP3 when the input requires audio extraction or conversion.
|
|
106
111
|
|
|
107
112
|
Markdown paragraphs split at sentence boundaries after 30 seconds or 80 words, or
|
|
108
113
|
when the speaker changes. Polish speaker and known event labels are retained for
|
|
@@ -136,12 +141,6 @@ API transcription errors are returned without retrying on another account.
|
|
|
136
141
|
Audio is uploaded to Speechmatics in EU1. Transcription usage is billed by Speechmatics.
|
|
137
142
|
An API timeout can leave a remote job running; its ID is retained when available.
|
|
138
143
|
|
|
139
|
-
## Development
|
|
140
|
-
|
|
141
|
-
Run npm ci followed by npm run check. The checks use offline API fixtures.
|
|
142
|
-
See the [technical reference](https://github.com/kucharskill/mcp-speechmatics-transcribe/blob/main/docs/technical.md)
|
|
143
|
-
for CLI integration, discovery behavior, and release maintenance.
|
|
144
|
-
|
|
145
144
|
## License
|
|
146
145
|
|
|
147
146
|
MIT. This project is an independent client and is not affiliated with Speechmatics.
|
package/cli.js
CHANGED
|
@@ -19,8 +19,6 @@ const program = new Command()
|
|
|
19
19
|
.addOption(new Option("--diarization <mode>", `Diarization (default: ${defaults.diarization})`).choices(optionFields.diarization.options))
|
|
20
20
|
.option("--audio-events", "Detect laughter, music, and applause with Standard or Enhanced (enabled by default)")
|
|
21
21
|
.option("--no-audio-events", "Disable audio event detection")
|
|
22
|
-
.option("--convert-to-mp3", "Convert non-MP3 input using FFmpeg")
|
|
23
|
-
.option("--no-convert-to-mp3", "Disable MP3 conversion")
|
|
24
22
|
.option("--timeout-seconds <seconds>", `API timeout (default: ${defaults.timeoutSeconds} seconds)`, Number)
|
|
25
23
|
.addHelpText("after", "\nPrecedence: CLI arguments, process environment, .env, built-in defaults.")
|
|
26
24
|
.hook("preAction", () => {
|
package/modules/config.js
CHANGED
|
@@ -9,7 +9,6 @@ const environmentSchema = z.object({
|
|
|
9
9
|
SPEECHMATICS_LANGUAGE: z.string().optional(),
|
|
10
10
|
SPEECHMATICS_DIARIZATION: z.string().optional(),
|
|
11
11
|
SPEECHMATICS_AUDIO_EVENTS: booleanSetting.optional(),
|
|
12
|
-
SPEECHMATICS_CONVERT_TO_MP3: booleanSetting.optional(),
|
|
13
12
|
SPEECHMATICS_TIMEOUT_SECONDS: z.coerce.number().int().positive().optional(),
|
|
14
13
|
});
|
|
15
14
|
const tokenSchema = z.array(z.object({
|
|
@@ -48,7 +47,6 @@ export async function loadConfig(overrides = {}, { requireTokens = true } = {})
|
|
|
48
47
|
language: env.SPEECHMATICS_LANGUAGE,
|
|
49
48
|
diarization: env.SPEECHMATICS_DIARIZATION,
|
|
50
49
|
audioEvents: env.SPEECHMATICS_AUDIO_EVENTS,
|
|
51
|
-
convertToMp3: env.SPEECHMATICS_CONVERT_TO_MP3,
|
|
52
50
|
timeoutSeconds: env.SPEECHMATICS_TIMEOUT_SECONDS,
|
|
53
51
|
};
|
|
54
52
|
const defined = (values) => Object.fromEntries(Object.entries(values).filter(([, value]) => value !== undefined));
|
package/modules/options.js
CHANGED
|
@@ -5,7 +5,6 @@ export const defaults = {
|
|
|
5
5
|
language: "pl",
|
|
6
6
|
diarization: "speaker",
|
|
7
7
|
audioEvents: true,
|
|
8
|
-
convertToMp3: false,
|
|
9
8
|
timeoutSeconds: 900,
|
|
10
9
|
};
|
|
11
10
|
|
|
@@ -14,7 +13,6 @@ export const optionFields = {
|
|
|
14
13
|
language: z.string().trim().min(1),
|
|
15
14
|
diarization: z.enum(["none", "speaker", "channel"]),
|
|
16
15
|
audioEvents: z.boolean(),
|
|
17
|
-
convertToMp3: z.boolean(),
|
|
18
16
|
timeoutSeconds: z.int().positive().max(86400),
|
|
19
17
|
};
|
|
20
18
|
|
package/modules/tools.js
CHANGED
|
@@ -11,14 +11,13 @@ export function createTools(configuredDefaults) {
|
|
|
11
11
|
return {
|
|
12
12
|
transcribe: {
|
|
13
13
|
definition: {
|
|
14
|
-
description: `${description} Return paths to raw JSON, segments, WebVTT subtitles, and Markdown.`,
|
|
14
|
+
description: `${description} MP3, AAC, OGG, M4A, and FLAC files are uploaded unchanged. Other formats are automatically prepared as MP3 using FFmpeg from PATH. Return paths to raw JSON, segments, WebVTT subtitles, and Markdown.`,
|
|
15
15
|
inputSchema: z.strictObject({
|
|
16
16
|
file: z.string().min(1).describe("Absolute path to a local audio or video file."),
|
|
17
17
|
model: optionFields.model.optional().describe(`Configured default: ${configuredDefaults.model}. enhanced: highest accuracy for a selected language. standard: faster processing and archival transcription. melia-1: MULTILANGUAGE, language switching within recordings. oak-1: MULTILANGUAGE, healthcare recordings. Use language=multi for melia-1 and oak-1; neither supports audio events.`),
|
|
18
18
|
language: optionFields.language.optional().describe(`Configured default: ${configuredDefaults.language}. Language code such as pl or en for enhanced/standard. Use multi for MULTILANGUAGE models melia-1 and oak-1.`),
|
|
19
19
|
disableDiarization: z.boolean().optional().describe(`Configured speaker diarization: ${configuredDefaults.diarization === "none" ? "disabled" : "enabled"}. Set true to disable it. Omit or pass false to use the server setting.`),
|
|
20
20
|
audioEvents: optionFields.audioEvents.optional().describe(`Configured default: ${configuredDefaults.audioEvents}. Detect laughter, music, and applause with Standard/Enhanced. Automatically disabled for melia-1/oak-1. Set false to disable.`),
|
|
21
|
-
convertToMp3: optionFields.convertToMp3.optional().describe(`Configured default: ${configuredDefaults.convertToMp3}. Convert non-MP3 files with system FFmpeg before uploading.`),
|
|
22
21
|
timeoutSeconds: optionFields.timeoutSeconds.optional().describe(`Configured default: ${configuredDefaults.timeoutSeconds} seconds. Upload and API processing timeout, independent of recording duration.`),
|
|
23
22
|
}),
|
|
24
23
|
},
|
package/modules/transcribe.js
CHANGED
|
@@ -14,7 +14,7 @@ import { initializeUsage, refreshUsage, roundHours } from "./usage.js";
|
|
|
14
14
|
|
|
15
15
|
const ffmpeg = promisify(execFile);
|
|
16
16
|
|
|
17
|
-
async function convertAudio(input, output) {
|
|
17
|
+
export async function convertAudio(input, output) {
|
|
18
18
|
const args = ["-nostdin", "-hide_banner", "-loglevel", "error", "-y", "-i", input, "-map", "0:a:0"];
|
|
19
19
|
try {
|
|
20
20
|
await ffmpeg("ffmpeg", [...args, "-c:a", "copy", output], { windowsHide: true });
|
|
@@ -27,6 +27,8 @@ async function convertAudio(input, output) {
|
|
|
27
27
|
return "encoded";
|
|
28
28
|
} catch (error) {
|
|
29
29
|
await rm(output, { force: true });
|
|
30
|
+
if (error.code === "ENOENT") throw new Error("FFmpeg was not found in PATH.");
|
|
31
|
+
if (/matches no streams|does not contain any stream/i.test(error.stderr ?? "")) throw new Error("No audio stream was found in the input file.");
|
|
30
32
|
throw new Error(`FFmpeg could not convert the file: ${error.stderr?.trim() || error.message}`);
|
|
31
33
|
}
|
|
32
34
|
}
|
|
@@ -59,7 +61,7 @@ export async function transcribe(file, overrides = {}) {
|
|
|
59
61
|
await mkdir(directory, { recursive: true });
|
|
60
62
|
let convertedFile = null;
|
|
61
63
|
let conversion = null;
|
|
62
|
-
if (
|
|
64
|
+
if (![".mp3", ".aac", ".ogg", ".m4a", ".flac"].includes(extname(input).toLowerCase())) {
|
|
63
65
|
convertedFile = join(directory, `audio-${id}.mp3`);
|
|
64
66
|
conversion = await convertAudio(input, convertedFile);
|
|
65
67
|
}
|