mirror of
https://github.com/hanzoai/frames.git
synced 2026-09-24 00:08:03 +00:00
Voice is POST /v1/audio/speech and word timings come from POST /v1/audio/transcriptions over the rendered audio. Music, sound effects, images, and video generate through /v1/audio/music, /v1/audio/foley, /v1/images/generations, and /v1/videos/generations. The shared catalog is a listing under media/<type>/ in our own object store, browsed through /v1/s3 — an empty prefix reports itself as empty rather than reading as a bad query. One client (scripts/lib/api.mjs) holds every route and the one credential: a Hanzo IAM token in $HANZO_API_KEY, read from Hanzo KMS. No credential file, no per-repo .env, no per-provider CLI to install or keep current. $HANZO_BASE_URL points the same code at a local Hanzo Engine. Word timings are passed through, never interpolated: a caption cut on invented boundaries reads as correct and drifts against the voice. When the service returns text without them, the word array is empty and the caller is told. Deletes the provider cascade this replaces, its model ladders, and the account linking in telemetry — the install id stands alone.
26 lines
952 B
JavaScript
26 lines
952 B
JavaScript
import { MAX_SPEECH_INPUT, speech, write } from "./api.mjs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
|
|
// Voiceover through the one speech route. The service owns its voice catalog;
|
|
// pass ctx.voice to choose one, omit it for the service default.
|
|
export async function ttsGenerate(intent, ctx) {
|
|
if (Buffer.byteLength(intent, "utf8") > MAX_SPEECH_INPUT) {
|
|
console.error(`media-use: script exceeds the ${MAX_SPEECH_INPUT}-byte speech limit — split it`);
|
|
return null;
|
|
}
|
|
const out = join(tmpdir(), `media-use-voice-${process.pid}-${Date.now()}.mp3`);
|
|
const buf = await speech({ text: intent, voice: ctx?.voice, lang: ctx?.lang, format: "mp3" });
|
|
write(buf, out);
|
|
return {
|
|
localPath: out,
|
|
ext: ".mp3",
|
|
source: "generated",
|
|
metadata: {
|
|
description: intent,
|
|
provider: "hanzo.voice",
|
|
provenance: { prompt: intent, ...(ctx?.voice ? { voice: ctx.voice } : {}) },
|
|
},
|
|
};
|
|
}
|