Documentation
¶
Overview ¶
Package api is AudioSmith's Local API (M5): an HTTP server inside the app process that speaks OpenAI's audio API under /v1, AudioSmith's own API under /api (voices, takes, generation, transcripts, jobs, models, tools), job events as Server-Sent Events, streaming speech over a WebSocket (/ws/tts), its OpenAPI 3.1 description (/openapi.json, with a bundled reference viewer at /docs), and mounts the MCP server (/mcp, internal/mcp).
Every request goes through the app's services and its one job queue (interactive priority), as the UI's own work does: the API is a second client of the same domain, not a second engine. The engine may restart under it: requests then wait in the queue, or get 503 with Retry-After while no worker can run them. The licence gate applies (403).
Security (auth.go): the server listens on 127.0.0.1 only; Host and Origin are checked (DNS rebinding, browsers); state-changing /api routes need a CSRF header; an API key (Bearer) is optional on loopback and required by the "Require a key" setting; LAN sharing opens a second listener whose clients need a one-time 8-digit PIN (consumption routes) or the key.
The app (package main, api*.go) implements Backend over its library and engine; tests use a fake over the real job scheduler.
Imports: core, jobs, services (job params and results), catalog, settings, engine/proto, translate, lang, dsp/{wav,resample}.
Index ¶
- Constants
- Variables
- func Accepted(j JobJSON) map[string]any
- func DefaultModels(st settings.Settings) (tts, accurate, fast string)
- func DubTargets(st settings.Settings) []string
- func InputDir(param, path string) (string, error)
- func InputFile(param, path string) (string, error)
- func IsGroupJob(id string) bool
- func NewKey() string
- func OpenAIVoiceNames() []string
- func SafeName(name, fallback, ext string) string
- func WritePortFile(path string, p PortFile) error
- type AssetJSON
- type AssetQuery
- type AudiobookCreate
- type Backend
- type BatchErrorJSON
- type BatchItemJSON
- type BatchJSON
- type BatchRequest
- type BatchSettingsJSON
- type BookJSON
- type CastJSON
- type ChapterJSON
- type CharacterBackend
- type CloneParams
- type DesignParams
- type Designed
- type DialogueBlockJSON
- type DialogueBlockRef
- type DirectRequest
- type DubCreate
- type DubEdit
- type DubExport
- type DubJSON
- type DubQuery
- type DubRun
- type DubSegmentEdit
- type DubSegmentJSON
- type DubSpeakerJSON
- type DubStageJSON
- type DubStretchJSON
- type DubTrackJSON
- type Error
- type ExportJSON
- type FacetValueJSON
- type FitJSON
- type FitRequest
- type FormatEncoder
- type GalleryPage
- type GalleryQuery
- type GalleryUse
- type GalleryUseIn
- type GalleryVoiceJSON
- type Health
- type HintJSON
- type IsolateRequest
- type IsolationJSON
- type IsolationQuery
- type JobErrorJSON
- type JobJSON
- type LanguageJSON
- type LicenceJSON
- type LongformCreate
- type LongformExport
- type LongformJSON
- type LongformRender
- type LongformUpdate
- type Model
- type ModelJSON
- type Options
- type PortFile
- type ProbeJSON
- type ProbeRequest
- type ProblemJSON
- type ProgressJSON
- type ProjectJSON
- type ProjectQuery
- type RefCheckJSON
- type RefCheckRequest
- type RemovedModelJSON
- type RenderChapterOut
- type RenderJSON
- type Replacement
- type Route
- type SampleJSON
- type SampleOpen
- type SampleOpened
- type SegmentJSON
- type Server
- func (s *Server) Assets(ctx context.Context, q AssetQuery) ([]AssetJSON, error)
- func (s *Server) Batch(ctx context.Context) (BatchJSON, error)
- func (s *Server) BatchDub(ctx context.Context, req BatchRequest) (BatchJSON, error)
- func (s *Server) CancelJob(ctx context.Context, id string) (JobJSON, error)
- func (s *Server) CheckReference(ctx context.Context, req RefCheckRequest) (RefCheckJSON, error)
- func (s *Server) CloneVoice(ctx context.Context, p CloneParams) (core.Voice, error)
- func (s *Server) Close(ctx context.Context)
- func (s *Server) CreateDub(ctx context.Context, req DubCreate) (DubJSON, error)
- func (s *Server) CreateLongform(ctx context.Context, req LongformCreate) (LongformJSON, error)
- func (s *Server) Delete(ctx context.Context, kind, id string, confirm bool) error
- func (s *Server) DesignVoice(ctx context.Context, p DesignParams) (Designed, error)
- func (s *Server) DetectWatermark(ctx context.Context, path string) (WatermarkReport, error)
- func (s *Server) Direct(ctx context.Context, req DirectRequest) (translate.Direction, error)
- func (s *Server) DownloadModel(ctx context.Context, id string) (string, error)
- func (s *Server) Dub(ctx context.Context, req DubQuery) (DubJSON, error)
- func (s *Server) DuplicateVoice(ctx context.Context, req VoiceDuplicate) (core.Voice, error)
- func (s *Server) EditDub(ctx context.Context, req DubEdit) (DubJSON, error)
- func (s *Server) ExportDub(ctx context.Context, req DubExport) (JobJSON, error)
- func (s *Server) ExportLongform(ctx context.Context, req LongformExport) (ExportJSON, error)
- func (s *Server) ExportTake(ctx context.Context, req TakeExport) (ExportJSON, error)
- func (s *Server) ExportTranscript(ctx context.Context, req TranscriptExport) (ExportJSON, error)
- func (s *Server) ExportVoice(ctx context.Context, req VoiceExportRequest) (ExportJSON, error)
- func (s *Server) Fit(ctx context.Context, req FitRequest) (FitJSON, error)
- func (s *Server) Handler() http.Handler
- func (s *Server) Health() Health
- func (s *Server) ImportVoice(ctx context.Context, req VoiceImportRequest) (VoiceImported, error)
- func (s *Server) Isolation(ctx context.Context, id string) (IsolationJSON, error)
- func (s *Server) Isolations(ctx context.Context) ([]IsolationJSON, error)
- func (s *Server) Job(ctx context.Context, id string, wait time.Duration) (JobJSON, error)
- func (s *Server) Key() string
- func (s *Server) LANHandler(port int) http.Handler
- func (s *Server) Languages(model string) ([]LanguageJSON, error)
- func (s *Server) LastRequest() time.Time
- func (s *Server) Longform(ctx context.Context, id string) (LongformJSON, error)
- func (s *Server) MountMCP(h http.Handler)
- func (s *Server) OpenSample(ctx context.Context, id string) (SampleOpened, error)
- func (s *Server) OutputDir() string
- func (s *Server) OutputFile(dir, name, fallback, ext string) (string, error)
- func (s *Server) OutputFolder(dir string) (string, error)
- func (s *Server) Port() int
- func (s *Server) Probe(ctx context.Context, req ProbeRequest) (ProbeJSON, error)
- func (s *Server) Projects(ctx context.Context, q ProjectQuery) ([]ProjectJSON, error)
- func (s *Server) RenderLongform(ctx context.Context, req LongformRender) (JobJSON, error)
- func (s *Server) RenewPIN() (Share, bool)
- func (s *Server) Routes() []Route
- func (s *Server) RunDub(ctx context.Context, req DubRun) (JobJSON, error)
- func (s *Server) RunWorkflow(ctx context.Context, req WorkflowRun) (JobJSON, error)
- func (s *Server) Samples(ctx context.Context) ([]SampleJSON, error)
- func (s *Server) SearchGallery(ctx context.Context, q GalleryQuery) (GalleryPage, error)
- func (s *Server) SetKey(key string)
- func (s *Server) Sharing() (Share, bool)
- func (s *Server) Spec() []byte
- func (s *Server) Start(port int) error
- func (s *Server) StartIsolation(ctx context.Context, req IsolateRequest) (IsolationJSON, error)
- func (s *Server) StartLAN(port int) (Share, error)
- func (s *Server) StartSpeech(ctx context.Context, p SpeechParams) (*Speech, error)
- func (s *Server) Stop(ctx context.Context)
- func (s *Server) StopLAN()
- func (s *Server) Studio() (Studio, error)
- func (s *Server) TakeFile(t core.Take) string
- func (s *Server) Toolkit() (Toolkit, error)
- func (s *Server) Transcribe(ctx context.Context, p TranscribeParams) (Transcription, error)
- func (s *Server) TranslateToEnglish(ctx context.Context, t core.Transcript) (core.Transcript, error)
- func (s *Server) UpdateLongform(ctx context.Context, req LongformUpdate) (LongformJSON, error)
- func (s *Server) UpdateVoice(ctx context.Context, req VoiceUpdate) (core.Voice, error)
- func (s *Server) UseGalleryVoice(ctx context.Context, id string) (GalleryUse, error)
- func (s *Server) VoicePreview(ctx context.Context, q VoicePreviewQuery) (VoicePreview, error)
- func (s *Server) Workflows(ctx context.Context) ([]WorkflowJSON, error)
- func (s *Server) WriteStory(ctx context.Context, req StoryDraftRequest) (StoryDraftJSON, error)
- type Share
- type SkillSource
- type SpeakRequest
- type SpeakerJSON
- type SpecOperation
- type Speech
- type SpeechParams
- type SpeechResult
- type Status
- type StemJSON
- type StoryCreate
- type StoryDraftJSON
- type StoryDraftRequest
- type StoryLineIn
- type StoryLineJSON
- type Studio
- type TakeExport
- type TakeJSON
- type Toolkit
- type TranscribeParams
- type TranscriptExport
- type TranscriptJSON
- type Transcription
- type VoiceDuplicate
- type VoiceExportRequest
- type VoiceImportRequest
- type VoiceImported
- type VoiceJSON
- type VoicePreview
- type VoicePreviewQuery
- type VoiceUpdate
- type WatchFolderJSON
- type WatermarkReport
- type WatermarkRequest
- type WordJSON
- type WorkflowJSON
- type WorkflowRun
- type WorkflowRunOut
Constants ¶
const ( FormatWAV = "wav" FormatPCM = "pcm" FormatAAC = "aac" // AAC-LC in an MP4 (M4A) container: media.encode FormatM4A = "m4a" FormatMP3 = "mp3" FormatOpus = "opus" FormatFLAC = "flac" )
Response formats.
const ( // HeaderCSRF must be on state-changing /api requests that carry no // API key (any value): a page in a browser cannot send it to another // origin without a CORS preflight, which the server refuses. HeaderCSRF = "X-AudioSmith-Request" // HeaderPIN carries the LAN sharing PIN (also ?pin= or the cookie). HeaderPIN = "X-AudioSmith-Pin" // HeaderClient names the client (agent) for per-agent voices. HeaderClient = "X-AudioSmith-Client" // HeaderVia is set by the server (never by clients) on requests it // passes on: ViaLoopback, ViaLAN (PIN) or ViaLANKey. The MCP server // reads it to decide whether a tool may read files by path. HeaderVia = "X-AudioSmith-Via" )
Request headers of the API.
const ( ViaLoopback = "loopback" ViaLAN = "lan" ViaLANKey = "lan-key" )
Values of HeaderVia.
const ( StateReady = "ready" StateStarting = "starting" StateRestarting = "restarting" StateFailed = "failed" StateStopped = "stopped" )
Engine states.
const ( CodeInvalid = "invalid_request" CodeNotFound = "not_found" CodeModelNotFound = "model_not_found" CodeVoiceNotFound = "voice_not_found" CodeAmbiguousVoice = "ambiguous_voice" CodeUnsupportedFormat = "unsupported_format" CodeUnsupportedModel = "unsupported_model" // the model can't do what was asked (a TTS model for STT…) CodeQueueTimeout = "queue_timeout" CodeForbiddenHost = "forbidden_host" CodeForbiddenOrigin = "forbidden_origin" CodeCSRF = "csrf_header_missing" CodeTooManyAttempts = "too_many_attempts" CodeNotDownloaded = proto.CodeModelNotDownloaded CodeLicenceRequired = proto.CodeLicenceRequired CodeTranslationNotReady = "translation_unavailable" // no language model for /v1/audio/translations CodePathNotAllowed = "path_not_allowed" CodeTooLarge = "too_large" // CodeDiskFull: not enough free disk space for the work (507; data // need and free, bytes, when a pre-check refused it). CodeDiskFull = core.CodeDiskFull // CodeModelRemoved: the request names a model AudioSmith removed // (thread #43) and its replacement can't do what was asked (a // built-in speaker of the old model, a download). Requests the // replacement can serve are answered by it, with replaced_by. CodeModelRemoved = "model_removed" // CodeNeedsReference: the model only clones voices and the request // gave no reference (ref_audio, or a saved voice // cloned from a clip). 400. CodeNeedsReference = core.CodeNeedsReference )
Error codes the API adds to the engine's (proto.Code*) and the services' ones.
const ( SourceURL = "https://github.com/hehehai/AudioSmith" License = "AGPL-3.0-only" )
AudioSmith's source code and licence (an SPDX identifier). The About page shows them too.
const ( CodeConfirmRequired = "confirm_required" CodeUnsupported = "unsupported" CodeDirectorFailed = "director_failed" // the language model failed (timeout, unreadable answer…) )
Codes of this file's errors.
const ( DeleteTake = "take" DeleteVoice = "voice" DeleteTranscript = "transcript" DeleteProject = "project" // a Stories or Audiobook project DeleteDub = "dub" DeleteIsolation = "isolation" // a Voice isolator's stems (kit.go) )
Delete kinds.
const MaxInput = 100_000
MaxInput is the longest text of one native or MCP speech request (OpenAI's route keeps OpenAI's 4096): longer scripts belong in Audiobook or Stories.
const MaxOffset = 1 << 30
MaxOffset is the largest offset a list takes, over REST and MCP alike.
const MaxOpenAIInput = 4096
MaxOpenAIInput is OpenAI's limit on /v1/audio/speech's input.
const MaxUpload = 1 << 30 // 1 GiB
MaxUpload bounds an uploaded file (audio, video, a voice reference).
const MaxWait = 60 * time.Second
MaxWait bounds a job request's long poll.
const PCMRate = 24000
PCMRate is the rate of OpenAI's "pcm" format: 24 kHz, 16-bit signed little-endian, mono.
const PortFileName = "api.json"
PortFileName is the port file's name in the data folder.
Variables ¶
var AssetKinds = []string{"speech", "story", "audiobook", "dub", "stems", "import"}
AssetKinds are the kinds of Assets.
var DeleteKinds = []string{DeleteTake, DeleteVoice, DeleteTranscript, DeleteProject, DeleteDub, DeleteIsolation}
DeleteKinds lists them.
var ErrPortInUse = errors.New("the port is in use")
ErrPortInUse says another program listens on the port.
var GroupPrefixes = []string{"longform:", "dub:", "workflow:"}
GroupPrefixes are the prefixes of group job ids: the owners of their jobs.
Functions ¶
func DefaultModels ¶
DefaultModels are the models a request without one gets: speech, Transcribe's Accurate and Fast (MCP's get_settings shows them).
func DubTargets ¶
DubTargets are the languages a new dub is made in: Settings → Dubbing's, else the default (services.DefaultBatchSettings').
func InputFile ¶
InputFile resolves an input path: absolute (~/ works), an existing, readable regular file. It returns the path with symlinks resolved.
func IsGroupJob ¶
IsGroupJob reports whether id names a group of jobs.
func SafeName ¶
SafeName is a file name for name ("" or unusable: fallback) with the extension ext (added unless it has it); never a path.
func WritePortFile ¶
WritePortFile writes the port file atomically.
Types ¶
type AssetJSON ¶
type AssetJSON struct {
ID string `json:"id"` // take:…, render:…, export:…, stem:…, in:…
Kind string `json:"kind"`
Title string `json:"title"`
Detail string `json:"detail,omitempty"`
File string `json:"file"`
Seconds float64 `json:"seconds,omitempty"`
At time.Time `json:"at"`
Page string `json:"page"` // the tool it came from: /studio, /stories…
Tool string `json:"tool,omitempty"` // the MCP tool that opens its source
Source string `json:"source_id,omitempty"`
}
AssetJSON is a file of Assets: an output or an imported file.
type AssetQuery ¶
type AssetQuery struct {
Kind string `json:"kind,omitempty" jsonschema:"speech, story, audiobook, dub, stems or import; empty: all."`
Search string `json:"search,omitempty" jsonschema:"Words in the title, the text or the file's path."`
Limit int `json:"limit,omitempty" jsonschema:"At most this many, newest first (default 50, up to 500)."`
Offset int `json:"offset,omitempty" jsonschema:"Skip this many (paging)."`
}
AssetQuery lists Assets.
type AudiobookCreate ¶
type AudiobookCreate struct {
Title string `json:"title,omitempty" jsonschema:"The book's title; empty: the book's own or the file's."`
Path string `json:"path,omitempty" jsonschema:"Absolute path of the book: EPUB, TXT, Markdown or DOCX (headings become chapters)."`
Text string `` /* 226-byte string literal not displayed */
Model string `json:"model,omitempty" jsonschema:"A speech model id (list_models); empty: AudioSmith's default."`
Voice string `` /* 160-byte string literal not displayed */
Cast map[string]string `json:"cast,omitempty" jsonschema:"[voice:NAME] name → voice (name or id, or a built-in speaker)."`
Language string `json:"language,omitempty" jsonschema:"BCP-47 code of the text; empty: the book's, else automatic."`
Format string `json:"format,omitempty" jsonschema:"wav (default) or m4b: also make an M4B audiobook with chapters and cover."`
}
AudiobookCreate is create_audiobook's input.
func (AudiobookCreate) Longform ¶
func (in AudiobookCreate) Longform() LongformCreate
Longform is the request of an audiobook's input.
type Backend ¶
type Backend interface {
// Status is the state of the engine (cheap, from memory).
Status() Status
// Settings are the app's settings (memory, no I/O): the API section,
// the Studio's and Transcribe's default models.
Settings() settings.Settings
// Models are the catalogue's entries with their local state.
Models(ctx context.Context) ([]Model, error)
// DownloadModel queues the download of a catalogue entry (licence
// accepted or not: the gate is for running) and returns its job id.
DownloadModel(ctx context.Context, id string) (string, error)
Voices(ctx context.Context, q core.VoiceQuery) ([]core.Voice, error)
Voice(ctx context.Context, id string) (core.Voice, error)
// SaveVoice creates (empty ID) a profile, copying files into it.
SaveVoice(ctx context.Context, v core.Voice, f core.VoiceFiles) (core.Voice, error)
DeleteVoice(ctx context.Context, id string) error
// VoiceFile is the absolute path of one of a voice's files.
VoiceFile(v core.Voice, name string) string
// VoiceFits reports whether model e can speak with v, and why not
// (English).
VoiceFits(v core.Voice, e catalog.Entry) (bool, string)
// Generate builds the take recipe of req (the voice applied for the
// model, instructions mapped to what the model takes) and queues it
// as the take req.ID (job owner "take:<req.ID>"), interactive unless
// req.Background. It returns the recipe and the job id, or refuses
// at once: *core.LicenceRequiredError, core.ErrNotDownloaded,
// core.ErrInvalid.
Generate(ctx context.Context, req SpeakRequest) (core.Take, string, error)
Takes(ctx context.Context, q core.TakeQuery) ([]core.Take, error)
Take(ctx context.Context, id string) (core.Take, error)
TakeAudio(t core.Take) string
// TakeSaved waits until the take id that Generate queued is in the
// history (its job ends just before), or will never be.
TakeSaved(ctx context.Context, id string) error
DeleteTake(ctx context.Context, id string) error
// Transcribe queues a transcription (owner "transcript:<req.ID>",
// req.ID set by the caller) and returns its job id.
Transcribe(ctx context.Context, req services.TranscribeRequest) (string, error)
Transcripts(ctx context.Context, q core.TranscriptQuery) ([]core.Transcript, error)
Transcript(ctx context.Context, id string) (core.Transcript, error)
DeleteTranscript(ctx context.Context, id string) error
// Translate translates with the language models of Settings →
// Writing help; core.ErrUnsupported when none is set up.
Translate(ctx context.Context, req translate.Request) (translate.Result, error)
// Direct parses a performance note (never fails: keywords without
// a language model).
Direct(ctx context.Context, note string) translate.Direction
// Fit predicts whether a line fits a slot (and may shorten it).
Fit(ctx context.Context, req translate.FitRequest) (translate.FitResult, error)
// Probe describes a media file (the engine's media worker).
Probe(ctx context.Context, path string) (proto.ProbeResult, error)
// CanEncode reports whether media.encode runs (M4A/AAC output).
CanEncode() bool
// DetectWatermark checks a file for the invisible watermark
// (AudioSeal, thread #14): core.ErrNotDownloaded without the model.
DetectWatermark(ctx context.Context, path string) (proto.WatermarkDetectResult, error)
// TempDir holds uploads and encoded responses (removed after use);
// DataDir is the app's data folder (the MCP sandbox's default parent).
TempDir() string
DataDir() string
}
Backend is what the API needs from the app. Every method is goroutine-safe and may block on I/O.
type BatchErrorJSON ¶
type BatchErrorJSON struct {
Path string `json:"path"`
Code string `json:"code"`
Message string `json:"message"`
}
BatchErrorJSON is a file the batch could not take.
type BatchItemJSON ¶
type BatchItemJSON struct {
ID string `json:"dub_id"`
JobID string `json:"job_id"`
Title string `json:"title"`
Source string `json:"source"`
Languages []string `json:"target_languages"`
Phase string `json:"phase"`
Updated string `json:"updated_at,omitempty"`
}
BatchItemJSON is a video of the batch queue.
type BatchJSON ¶
type BatchJSON struct {
Added []BatchItemJSON `json:"added,omitempty"`
Errors []BatchErrorJSON `json:"errors,omitempty"`
Queue []BatchItemJSON `json:"queue,omitempty"`
Watch *WatchFolderJSON `json:"watch_folder,omitempty"`
Prefs *BatchSettingsJSON `json:"settings,omitempty"`
// Warning: the request named a removed model; its replacement is used.
Warning string `json:"warning,omitempty"`
}
BatchJSON is the batch queue (and what a request added).
type BatchRequest ¶
type BatchRequest struct {
Paths []string `json:"paths,omitempty" jsonschema:"Absolute paths of videos or audio files."`
Folder string `json:"folder,omitempty" jsonschema:"Or an absolute folder: every video and audio file in it (not its subfolders)."`
Targets []string `json:"target_languages,omitempty" jsonschema:"BCP-47 codes to dub into; empty: the Batch page's."`
SourceLanguage string `json:"source_language,omitempty" jsonschema:"BCP-47 code spoken; empty: the Batch page's (or detected)."`
Voice string `` /* 143-byte string literal not displayed */
Model string `json:"model,omitempty" jsonschema:"The speech model; empty: the Batch page's (or the dubbing default)."`
KeepBackground *bool `json:"keep_background,omitempty" jsonschema:"Keep music and effects; empty: the Batch page's."`
Dialogue string `` /* 188-byte string literal not displayed */
}
BatchRequest dubs files with the batch queue.
type BatchSettingsJSON ¶
type BatchSettingsJSON struct {
Targets []string `json:"target_languages"`
SourceLanguage string `json:"source_language,omitempty"`
Voice string `json:"voice,omitempty"`
Model string `json:"model,omitempty"`
KeepBackground bool `json:"keep_background"`
Translator string `json:"translator,omitempty"`
Dialogue string `json:"dialogue,omitempty"`
}
BatchSettingsJSON are the Batch page's settings.
type BookJSON ¶
type BookJSON struct {
Author string `json:"author,omitempty"`
Narrator string `json:"narrator,omitempty"`
Year string `json:"year,omitempty"`
Genre string `json:"genre,omitempty"`
Description string `json:"description,omitempty"`
Cover string `json:"cover,omitempty"`
Loudness string `json:"loudness,omitempty"` // acx, podcast or ""
}
BookJSON are a book's details.
type CastJSON ¶
type CastJSON struct {
Name string `json:"name"`
Voice string `json:"voice,omitempty"` // a reference: a voice id, "speaker:<id>"
VoiceName string `json:"voice_name,omitempty"`
Lines int `json:"lines,omitempty"`
Persona string `json:"persona,omitempty"` // stories: the character's performance baseline
// Dialogue: an audiobook's name that speaks in a dialogue block.
Dialogue bool `json:"dialogue,omitempty"`
}
CastJSON is a character and the voice that plays it.
type ChapterJSON ¶
type ChapterJSON struct {
Index int `json:"index"` // 1-based
Title string `json:"title,omitempty"`
Lines int `json:"lines"`
Chars int `json:"chars"`
}
ChapterJSON is a chapter of a project.
type CharacterBackend ¶
type CharacterBackend interface {
CharacterVoice(ctx context.Context, name string) (id string, ok bool)
}
CharacterBackend is a Backend that speaks with the characters of an outside engine (VOICEVOX, AivisSpeech; thread #171): CharacterVoice finds one by its voice id or its name ("ずんだもん", "ずんだもん/ノーマル") among those of the engines that answer.
type CloneParams ¶
type CloneParams struct {
Name string
File string // the reference (any audio AVFoundation reads)
RefText string // what it says; "" lets the engine listen
Language string
Style string
}
CloneParams makes a cloned voice.
type DesignParams ¶
type DesignParams struct {
Name string `json:"name"`
Description string `json:"description"`
Language string `json:"language,omitempty"`
Seed int64 `json:"seed,omitempty"` // 0 = a new one
Model string `json:"model,omitempty"` // a design model; "" = the first
}
DesignParams makes a designed voice.
type Designed ¶
type Designed struct {
Voice core.Voice
Unmatched []string // words the parser could not map
Model catalog.Entry
}
Designed is a designed voice and how its description was read.
type DialogueBlockJSON ¶
type DialogueBlockJSON struct {
Chapter int `json:"chapter"` // 1-based
Index int `json:"index"` // 1-based in its chapter (render_longform's dialogue_block)
Start int `json:"start"` // byte offsets of the block in script
End int `json:"end"`
Speakers []string `json:"speakers"`
Lines int `json:"lines"` // lines with a speaker
Uncast []string `json:"uncast,omitempty"` // speakers without a voice: render_longform gives them their own
// Mode is dialogue (the dialogue model speaks it) or per_line (each
// line in its voice on the book's model), Reason why per_line:
// dialogue_off, not_downloaded, memory, language or one_speaker.
Mode string `json:"mode"`
Reason string `json:"reason,omitempty"`
}
DialogueBlockJSON is a dialogue block of an audiobook's manuscript ([dialogue] … [/dialogue]): where it is, who speaks, and how it is made.
type DialogueBlockRef ¶
type DialogueBlockRef struct {
Chapter int `json:"chapter" jsonschema:"The block's chapter (1-based)."`
Index int `json:"index" jsonschema:"The block's index in its chapter (1-based)."`
}
DialogueBlockRef names a dialogue block: its chapter (1-based) and its index in the chapter (1-based).
type DirectRequest ¶
type DirectRequest struct {
Note string `json:"note" jsonschema:"A performance note in your own words (whispered, getting angry, a tired smile…)."`
}
DirectRequest reads a performance note.
type DubCreate ¶
type DubCreate struct {
Path string `json:"path,omitempty" jsonschema:"Absolute path of the video or audio to dub (mp4, mov, mkv, mp3, wav, m4a…)."`
URL string `` /* 200-byte string literal not displayed */
Title string `json:"title,omitempty" jsonschema:"The project's title; empty: the file's name."`
SourceLanguage string `json:"source_language,omitempty" jsonschema:"BCP-47 code spoken in the file; empty: detected."`
Targets []string `` /* 186-byte string literal not displayed */
Model string `` /* 129-byte string literal not displayed */
Voice string `` /* 134-byte string literal not displayed */
Speakers int `json:"speakers,omitempty" jsonschema:"How many people speak (1–20); 0: detected."`
KeepBackground *bool `json:"keep_background,omitempty" jsonschema:"Keep the music and effects under the dub (default true)."`
Through string `json:"through,omitempty" jsonschema:"How far to run now: transcript, translation, dub (default: the whole dub) or none."`
Dialogue string `` /* 283-byte string literal not displayed */
DialogueModel string `` /* 204-byte string literal not displayed */
}
DubCreate makes a dub of a file and, unless Through is "none", starts it.
type DubEdit ¶
type DubEdit struct {
ID string `json:"dub_id" jsonschema:"The dub."`
Segments []DubSegmentEdit `json:"segments,omitempty" jsonschema:"Line edits."`
Cast map[string]string `` /* 133-byte string literal not displayed */
Names map[string]string `json:"names,omitempty" jsonschema:"Speaker label → display name."`
Dialogue string `` /* 283-byte string literal not displayed */
DialogueModel string `` /* 204-byte string literal not displayed */
}
DubEdit edits lines and the cast of a dub.
type DubExport ¶
type DubExport struct {
ID string `json:"dub_id" jsonschema:"The dub."`
Format string `` /* 224-byte string literal not displayed */
Language string `json:"language,omitempty" jsonschema:"The language of a track or subtitles (orig: the source's); empty: the main target."`
Tracks []string `json:"tracks,omitempty" jsonschema:"mp4: the audio tracks, languages and orig; empty: the main target and orig."`
Default string `json:"default_track,omitempty" jsonschema:"mp4: the track players pick; empty: the first."`
Subtitles bool `json:"subtitles,omitempty" jsonschema:"mp4: add soft subtitle tracks."`
Dual bool `json:"dual,omitempty" jsonschema:"Subtitles with the translation and the original."`
Bits int `json:"bits,omitempty" jsonschema:"wav: 16, 24 (default) or 32."`
Dir string `json:"directory,omitempty" jsonschema:"Absolute folder to write to; empty: AudioSmith's agents' folder."`
Filename string `json:"filename,omitempty" jsonschema:"The file's name (no folders); empty: from the title and language."`
Output string `json:"-"`
}
DubExport saves a dub.
type DubJSON ¶
type DubJSON struct {
ID string `json:"dub_id"`
Title string `json:"title"`
Source string `json:"source"`
Duration float64 `json:"duration,omitempty"`
SourceLang string `json:"source_language,omitempty"`
Detected string `json:"detected_language,omitempty"`
Targets []string `json:"target_languages"`
Phase string `json:"phase"`
Model string `json:"model,omitempty"`
Translator string `json:"translator,omitempty"`
Batch bool `json:"batch,omitempty"`
Running bool `json:"running"`
JobID string `json:"job_id"` // "dub:<dub_id>"
Speakers []DubSpeakerJSON `json:"speakers,omitempty"`
Stages map[string]DubStageJSON `json:"stages,omitempty"`
Tracks map[string]DubTrackJSON `json:"tracks,omitempty"`
Language string `json:"language,omitempty"` // of the translations shown
Segments []DubSegmentJSON `json:"segments,omitempty"`
Updated time.Time `json:"updated_at"`
// Dialogue is "auto" or "off" (multi-speaker dialogue), DialogueModel
// its model (soulx); DialogueBlocked why language's track is made line
// by line all the same (off, voice_match, language, speakers, memory,
// model); DialogueStretches language's conversations.
Dialogue string `json:"dialogue"`
DialogueModel string `json:"dialogue_model,omitempty"`
DialogueBlocked string `json:"dialogue_blocked,omitempty"`
DialogueStretches []DubStretchJSON `json:"dialogue_stretches,omitempty"`
// Warning: the request named a removed model; its replacement is used.
Warning string `json:"warning,omitempty"`
}
DubJSON is a dub project.
type DubQuery ¶
type DubQuery struct {
ID string `json:"dub_id" jsonschema:"The dub (create_dub or list_projects with category dub)."`
Language string `json:"language,omitempty" jsonschema:"The target language whose translations to show; empty: the main one."`
Segments *bool `json:"segments,omitempty" jsonschema:"Include the lines (default true)."`
}
DubQuery reads a dub.
type DubRun ¶
type DubRun struct {
ID string `json:"dub_id" jsonschema:"The dub."`
Through string `json:"through,omitempty" jsonschema:"transcript, translation, dub (default) or verify (a second listen that flags lines)."`
Languages []string `json:"languages,omitempty" jsonschema:"Only these target languages; empty: all."`
Retranslate bool `json:"retranslate,omitempty" jsonschema:"Translate every line again (edited lines too)."`
Retranscribe bool `json:"retranscribe,omitempty" jsonschema:"Transcribe the source again (drops the lines and their edits)."`
Segments []string `json:"segments,omitempty" jsonschema:"Only re-render these line ids; empty: the lines that changed."`
}
DubRun runs a dub's pipeline.
type DubSegmentEdit ¶
type DubSegmentEdit struct {
ID string `json:"id" jsonschema:"The line's id (get_dub)."`
Text string `json:"text,omitempty" jsonschema:"New source text (drops its translations, which are made again)."`
Language string `json:"language,omitempty" jsonschema:"With translation: its target language; empty: the main one."`
Trans string `json:"translation,omitempty" jsonschema:"New translated text in language."`
Speaker string `json:"speaker,omitempty" jsonschema:"Another speaker label (S1, S2…)."`
Voice string `json:"voice,omitempty" jsonschema:"A voice for this line only (a saved voice's name or id); default: the speaker's."`
NoDialogue *bool `` /* 173-byte string literal not displayed */
}
DubSegmentEdit changes one line of a dub.
type DubSegmentJSON ¶
type DubSegmentJSON struct {
ID string `json:"id"`
Start float64 `json:"start"`
End float64 `json:"end"`
Speaker string `json:"speaker,omitempty"`
Text string `json:"text"`
Translation string `json:"translation,omitempty"`
Voice string `json:"voice,omitempty"`
Rendered bool `json:"rendered,omitempty"`
Stale bool `json:"stale,omitempty"` // changed since its audio was made
Error string `json:"error,omitempty"`
// Dialogue is the conversation the line is in (dialogue_stretches,
// from 1; 0: none); MadeBy how its audio was made: "dialogue" (the
// multi-speaker model) or "single" (line by line); FallbackReason why
// a conversation line was made line by line (heard, length,
// segment_failed, unavailable); Flag that line's check failing too
// (heard: Heard is what the recognizer heard; length): listen to it.
Dialogue int `json:"dialogue,omitempty"`
MadeBy string `json:"made_by,omitempty"`
FallbackReason string `json:"fallback_reason,omitempty"`
Flag string `json:"flag,omitempty"`
Heard string `json:"heard,omitempty"`
NoDialogue bool `json:"no_dialogue,omitempty"`
}
DubSegmentJSON is a line of a dub.
type DubSpeakerJSON ¶
type DubSpeakerJSON struct {
Label string `json:"label"`
Name string `json:"name,omitempty"`
Voice string `json:"voice,omitempty"` // "" = cloned from the source
}
DubSpeakerJSON is a speaker and their voice.
type DubStageJSON ¶
type DubStageJSON struct {
Status string `json:"status"`
Code string `json:"code,omitempty"`
Message string `json:"message,omitempty"`
Warnings []string `json:"warnings,omitempty"`
}
DubStageJSON is a stage's last run.
type DubStretchJSON ¶
type DubStretchJSON struct {
Dialogue int `json:"dialogue"` // its number, from 1
Segments []string `json:"segments"` // its lines' ids, in time order
Speakers int `json:"speakers"` // its voices
}
DubStretchJSON is a conversation the dialogue model records together.
type DubTrackJSON ¶
type DubTrackJSON struct {
File string `json:"file,omitempty"`
Speech string `json:"speech,omitempty"`
Seconds float64 `json:"seconds,omitempty"`
Flagged int `json:"flagged,omitempty"` // lines a verify flagged
}
DubTrackJSON is a dubbed track.
type Error ¶
type Error struct {
Status int
Code string
Message string
Param string
Data map[string]any
// RetryAfter, in seconds, is sent as Retry-After (503, 429).
RetryAfter int
}
Error is an API error: an HTTP status and OpenAI's error object ({"error":{"message","type","param","code"}}), plus AudioSmith's data (the licence to accept, the model to download…). Messages are English.
func ErrConfirm ¶
ErrConfirm is the error of a delete without confirm.
type ExportJSON ¶
type ExportJSON struct {
Files []string `json:"files"`
Format string `json:"format"`
Bytes int64 `json:"bytes,omitempty"`
Seconds float64 `json:"seconds,omitempty"`
Loudness float64 `json:"loudness_lufs,omitempty"`
}
ExportJSON is what an export wrote.
type FacetValueJSON ¶
type FacetValueJSON struct {
Value string `json:"value"`
Label string `json:"label"`
Count int `json:"count"`
}
FacetValueJSON is a filter value and how many voices it gives.
type FitJSON ¶
type FitJSON struct {
Fit translate.Fit `json:"fit"`
Rewrite string `json:"rewrite,omitempty"`
RewriteFit *translate.Fit `json:"rewrite_fit,omitempty"`
}
FitJSON is a fit's answer.
type FitRequest ¶
type FitRequest struct {
Text string `json:"text" jsonschema:"The line to speak."`
Language string `json:"language,omitempty" jsonschema:"Its language (BCP-47); empty: detected."`
Slot float64 `json:"slot" jsonschema:"The time it must fit, in seconds (> 0)."`
Speed float64 `json:"speed,omitempty" jsonschema:"The speaking rate it will be spoken at (1 = normal)."`
Source string `json:"source,omitempty" jsonschema:"The original line it translates, if any."`
SourceLang string `json:"source_language,omitempty" jsonschema:"The original's language."`
Rewrite bool `json:"rewrite,omitempty" jsonschema:"true asks the writing help for a shorter version when it does not fit."`
}
FitRequest checks whether a line fits a slot.
type FormatEncoder ¶
FormatEncoder is implemented by backends that also encode MP3, Opus or FLAC (M7a: through the optional ffmpeg, behind media.encode). A Backend without it answers those formats 400 unsupported_format.
type GalleryPage ¶
type GalleryPage struct {
Total int `json:"total"`
Offset int `json:"offset"`
Next int `json:"next"` // -1: none
Items []GalleryVoiceJSON `json:"voices"`
Facets map[string][]FacetValueJSON `json:"facets,omitempty"`
}
GalleryPage is a page of results.
type GalleryQuery ¶
type GalleryQuery struct {
ID string `` /* 131-byte string literal not displayed */
Query string `` /* 131-byte string literal not displayed */
Category string `json:"category,omitempty" jsonschema:"A use case: narration, conversational, characters or announcing."`
Gender string `json:"gender,omitempty" jsonschema:"female or male."`
Age string `json:"age,omitempty" jsonschema:"child, teen, young_adult, middle_aged or elderly (see facets)."`
Language string `json:"language,omitempty" jsonschema:"The language it speaks (BCP-47 primary code: en, zh, ja…)."`
Limit int `json:"limit,omitempty" jsonschema:"At most this many (default 20, up to 100)."`
Offset int `json:"offset,omitempty" jsonschema:"Skip this many (paging)."`
}
GalleryQuery searches Discover voices with the page's filters.
type GalleryUse ¶
type GalleryUse struct {
Voice VoiceJSON `json:"voice"`
Created bool `json:"created"` // false: it was saved before
// Model is the model it was designed for; Models those that can speak
// it (design models render it as designed; others need its sample).
Model string `json:"model,omitempty"`
Models []string `json:"models,omitempty"`
Downloaded bool `json:"model_downloaded"`
Note string `json:"note,omitempty"`
}
GalleryUse is what "Use voice" made.
type GalleryUseIn ¶
type GalleryUseIn struct {
ID string `json:"id" jsonschema:"The voice's id from search_voices."`
}
GalleryUseIn is use_gallery_voice's input.
type GalleryVoiceJSON ¶
type GalleryVoiceJSON struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Category string `json:"category"` // the first use case
Uses []string `json:"uses,omitempty"` // every use case
Kind string `json:"kind,omitempty"` // "designed" or "builtin" ("": the earlier gallery)
Gender string `json:"gender,omitempty"`
Age string `json:"age,omitempty"`
Languages []string `json:"languages"`
Tags []string `json:"tags,omitempty"`
Attributes json.RawMessage `json:"attributes"`
Persona string `json:"persona,omitempty"` // a designed voice's description, as the model gets it
Model string `json:"model,omitempty"` // a built-in voice's model (catalogue id) and speaker
Speaker string `json:"speaker,omitempty"`
Sample string `json:"sample_text,omitempty"`
Featured bool `json:"featured,omitempty"`
Saved string `json:"saved_voice_id,omitempty"` // "Use voice" made it already
}
GalleryVoiceJSON is a voice of Discover voices (an archetype).
type Health ¶
type Health struct {
Status string `json:"status"` // "ok", "starting", "unavailable"
Version string `json:"version"`
Engine Status `json:"engine"`
// SourceURL and License: where to get AudioSmith's source, and its
// licence (AGPL-3.0 §13).
SourceURL string `json:"source_url"`
License string `json:"license"`
}
Health is GET /health's answer.
type IsolateRequest ¶
type IsolateRequest struct {
Path string `json:"path" jsonschema:"Absolute path of the audio or video file whose voices to separate (wav, mp3, m4a, mp4, mov…)."`
}
IsolateRequest starts an isolation.
type IsolationJSON ¶
type IsolationJSON struct {
ID string `json:"isolation_id"`
Title string `json:"title"`
Input string `json:"input"`
Video bool `json:"video,omitempty"`
Duration float64 `json:"duration,omitempty"`
State string `json:"state"` // queued, running, done, failed
JobID string `json:"job_id,omitempty"`
Error string `json:"error,omitempty"`
ErrorCode string `json:"error_code,omitempty"`
Stems []StemJSON `json:"stems,omitempty"`
Warnings []string `json:"warnings,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Next string `json:"next,omitempty"`
}
IsolationJSON is an isolation: one file's stems.
type IsolationQuery ¶
type IsolationQuery struct {
ID string `` /* 126-byte string literal not displayed */
// Stem asks for one stem's audio in the MCP result (inline/file as
// the output setting says).
Stem string `json:"stem,omitempty" jsonschema:"With isolation_id: also return this stem's audio: vocals, background or clean."`
Output string `` /* 142-byte string literal not displayed */
}
IsolationQuery reads isolations.
type JobErrorJSON ¶
type JobErrorJSON struct {
Code string `json:"code"`
Message string `json:"message"`
Data json.RawMessage `json:"data,omitempty"`
Retryable bool `json:"retryable,omitempty"`
}
JobErrorJSON is why a job failed.
type JobJSON ¶
type JobJSON struct {
ID string `json:"id"`
Object string `json:"object"` // "job"
Kind string `json:"kind"`
Lane string `json:"lane"`
State string `json:"state"`
Title string `json:"title,omitempty"`
Owner string `json:"owner,omitempty"`
Attempt int `json:"attempt,omitempty"`
Progress *ProgressJSON `json:"progress,omitempty"`
Error *JobErrorJSON `json:"error,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
// Done: it ended (succeeded, failed, cancelled or interrupted).
Done bool `json:"done"`
// Files are the absolute paths of what it made (thread #35).
Files []string `json:"files,omitempty"`
// Jobs are the queue jobs of a group job ("longform:<id>"…).
Jobs []string `json:"jobs,omitempty"`
}
JobJSON is a job of the queue.
type LanguageJSON ¶
type LanguageJSON struct {
Code string `json:"code"`
Name string `json:"name"`
Native string `json:"native,omitempty"`
Models []string `json:"models,omitempty"`
}
LanguageJSON is a language a model speaks.
type LicenceJSON ¶
type LicenceJSON struct {
ID string `json:"id"`
Name string `json:"name"`
URL string `json:"url,omitempty"`
Commercial bool `json:"commercial"`
// Needed: the licence must be accepted in AudioSmith before use (403
// licence_required until then).
Needed bool `json:"acceptance_needed"`
}
LicenceJSON is a model's licence.
type LongformCreate ¶
type LongformCreate struct {
Kind string `json:"-"` // "story" or "audiobook"
Title string `json:"title,omitempty"`
Path string `json:"path,omitempty"`
Text string `json:"text,omitempty"`
Lines []StoryLineIn `json:"lines,omitempty"`
Split string `json:"split,omitempty"`
Model string `json:"model,omitempty"`
Voice string `json:"voice,omitempty"`
Cast map[string]string `json:"cast,omitempty"`
Language string `json:"language,omitempty"`
Format string `json:"format,omitempty"`
}
LongformCreate makes a Stories or Audiobook project (REST body of POST /api/audiobooks and /api/stories).
type LongformExport ¶
type LongformExport struct {
ID string `json:"project_id" jsonschema:"The project; its last render is exported."`
Render string `json:"render_id,omitempty" jsonschema:"Or a render of it (render_longform's job, without longform:)."`
Format string `` /* 203-byte string literal not displayed */
Bits int `json:"bits,omitempty" jsonschema:"WAV bit depth: 16, 24 or 32 (float); 0: as rendered (32-bit float)."`
Dir string `json:"directory,omitempty" jsonschema:"Absolute folder to write to; empty: AudioSmith's agents' folder."`
Filename string `` /* 159-byte string literal not displayed */
}
LongformExport saves a finished render.
type LongformJSON ¶
type LongformJSON struct {
ID string `json:"project_id"`
Kind string `json:"kind"` // story, audiobook
Title string `json:"title"`
Model string `json:"model"` // catalogue id
Voice string `json:"voice,omitempty"`
VoiceName string `json:"voice_name,omitempty"`
Language string `json:"language,omitempty"`
Format string `json:"format"`
Stems bool `json:"stems,omitempty"`
Speed float64 `json:"speed,omitempty"`
Chapters []ChapterJSON `json:"chapters"`
Cast []CastJSON `json:"cast,omitempty"`
Lines []StoryLineJSON `json:"lines,omitempty"`
// Stories: the scene, the pacing (dialogue, reading, relaxed or
// fixed) and what the model does with scene, personas and directions
// (continuity: instruct, intensity or lines).
Scene string `json:"scene,omitempty"`
Pacing string `json:"pacing,omitempty"`
Continuity string `json:"continuity,omitempty"`
// Dialogue: the characters' lines are spoken by the dialogue model,
// a scene at a time (whole dialogue).
Dialogue bool `json:"dialogue,omitempty"`
DialogueModel string `json:"dialogue_model,omitempty"`
// Audiobooks: the manuscript (when it is at most 100 KB; longer ones
// are left out) and its dialogue blocks.
Script string `json:"script,omitempty"`
DialogueBlocks []DialogueBlockJSON `json:"dialogue_blocks,omitempty"`
Words int `json:"words"`
Estimate float64 `json:"estimated_seconds"`
Problems []ProblemJSON `json:"problems,omitempty"`
Book BookJSON `json:"book"`
Render *RenderJSON `json:"last_render,omitempty"`
Updated time.Time `json:"updated_at"`
// Warning: the request named a removed model; its replacement is used.
Warning string `json:"warning,omitempty"`
}
LongformJSON is a Stories or Audiobook project.
type LongformRender ¶
type LongformRender struct {
ID string `json:"project_id" jsonschema:"The project to render."`
Chapters []int `json:"chapters,omitempty" jsonschema:"Chapter numbers (1-based) to render; empty: the whole book or story."`
// DialogueBlock previews one dialogue block of an audiobook.
DialogueBlock *DialogueBlockRef `` /* 182-byte string literal not displayed */
}
LongformRender starts a render.
type LongformUpdate ¶
type LongformUpdate struct {
ID string `json:"project_id" jsonschema:"The project (create_audiobook, create_story or list_projects)."`
Title string `json:"title,omitempty" jsonschema:"A new title."`
Model string `json:"model,omitempty" jsonschema:"Another speech model (voices that do not fit it are reported as problems)."`
Voice string `json:"voice,omitempty" jsonschema:"The narrator (default voice): a saved voice's name or id, or a built-in speaker."`
Cast map[string]string `json:"cast,omitempty" jsonschema:"Character name → voice; the voice default gives the character the narrator's voice."`
Lines map[string]string `json:"line_voices,omitempty" jsonschema:"Stories: line id → voice for that line only (default: back to its character's)."`
Language string `json:"language,omitempty" jsonschema:"BCP-47 code; auto: automatic."`
Speed float64 `json:"speed,omitempty" jsonschema:"Speaking rate 0.5–2."`
Format string `json:"format,omitempty" jsonschema:"wav or m4b (M4B needs the engine's encoder)."`
Loudness string `json:"loudness,omitempty" jsonschema:"The book's loudness target: acx (Audible, −19 LUFS), podcast (−16 LUFS) or off."`
Author string `json:"author,omitempty" jsonschema:"Book details for the M4B's tags."`
Narrator string `json:"narrator,omitempty" jsonschema:"The narrator's name, for the M4B's tags."`
Year string `json:"year,omitempty" jsonschema:"The book's year, for its tags."`
Genre string `json:"genre,omitempty" jsonschema:"The book's genre, for its tags."`
About string `json:"description,omitempty" jsonschema:"The book's description, for its tags."`
Cover string `json:"cover,omitempty" jsonschema:"Absolute path of a PNG or JPEG cover (≤ 8 MB)."`
Stems *bool `json:"stems,omitempty" jsonschema:"true: renders also write one WAV per character (stems)."`
Script *string `` /* 381-byte string literal not displayed */
// Stories' performance.
Scene *string `` /* 191-byte string literal not displayed */
Personas map[string]string `` /* 143-byte string literal not displayed */
Directions map[string]string `` /* 169-byte string literal not displayed */
Emotions map[string]string `` /* 329-byte string literal not displayed */
Intensities map[string]int `` /* 166-byte string literal not displayed */
Pacing string `` /* 142-byte string literal not displayed */
Merge *bool `` /* 130-byte string literal not displayed */
Level *bool `` /* 134-byte string literal not displayed */
Dialogue *bool `` /* 393-byte string literal not displayed */
DialogueModel string `` /* 389-byte string literal not displayed */
Direct string `` /* 324-byte string literal not displayed */
}
LongformUpdate changes a project; empty fields stay as they are.
type Model ¶
type Model struct {
Entry catalog.Entry
Downloaded bool
// Licence says whether the licence must still be accepted before use.
LicenceNeeded bool
// Speakers are the voices of a model whose voices are not in the
// catalogue: an outside engine's characters (thread #171).
Speakers []SpeakerJSON
}
Model is a catalogue entry and its local state.
type ModelJSON ¶
type ModelJSON struct {
ID string `json:"id"`
Object string `json:"object"` // "model"
Label string `json:"label"` // technical name: "Qwen3-TTS 0.6B CustomVoice"
// DisplayName and Description are the friendly name and one line in
// English ("Standard voices"); UIName is the name AudioSmith's UI
// shows, in its language ("标准音色"); Tags are words of a fixed
// vocabulary ("chinese", "clone", "fast", "non-commercial"…), thread
// #45.
DisplayName string `json:"display_name"`
UIName string `json:"ui_name"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags"`
Repo string `json:"repo"`
Family string `json:"family"`
Tasks []string `json:"tasks"`
Capabilities []string `json:"capabilities"`
Languages []string `json:"languages,omitempty"` // BCP-47
Voices []SpeakerJSON `json:"voices,omitempty"` // built-in speakers
SampleRate int `json:"sample_rate,omitempty"`
MaxChars int `json:"max_chars,omitempty"`
RTF float64 `json:"rtf,omitempty"`
Size int64 `json:"size"`
MinMemoryGB float64 `json:"min_memory_gb,omitempty"`
// NeedsReference: the model only clones voices; speech requests need
// ref_audio or a saved cloned voice (else 400 needs_reference).
NeedsReference bool `json:"needs_reference,omitempty"`
Downloaded bool `json:"downloaded"`
Default bool `json:"default,omitempty"` // what OpenAI's names map to
Hidden bool `json:"hidden,omitempty"`
About string `json:"about,omitempty"`
Licence LicenceJSON `json:"licence"`
}
ModelJSON is a catalogue entry and its state.
type Options ¶
type Options struct {
Backend Backend
// Sched is the app's job queue: the API follows, cancels and lists
// its jobs; Bus carries their events (jobs.Updated).
Sched jobs.Scheduler
Bus *core.Bus
// Version is the app's version, for /health and the spec.
Version string
// Logf reports server errors; nil = log.Printf.
Logf func(format string, args ...any)
// Seen is told when a client's request passed the checks (not the
// public routes: health, discovery, the spec), at most once a second;
// nil = nobody (the Developers page's 「最近一次请求」).
Seen func(at time.Time)
// guard counted a wrong PIN or key: Sharing's Locked or Limited may
// have changed; nil = nobody.
ShareChanged func()
}
Options configure a Server. Backend, Sched and Bus are required.
type PortFile ¶
type PortFile struct {
URL string `json:"url"` // http://127.0.0.1:3901
Port int `json:"port"`
PID int `json:"pid"`
Version string `json:"version,omitempty"`
Started time.Time `json:"started"`
}
PortFile is what the running app writes to <data>/api.json so that the MCP stdio shim (AudioSmith --mcp-stdio) and scripts find the API.
func ReadPortFile ¶
ReadPortFile reads the port file.
type ProbeRequest ¶
type ProbeRequest struct {
Path string `json:"path" jsonschema:"Absolute path of an audio or video file."`
}
ProbeRequest probes a media file.
type ProblemJSON ¶
type ProblemJSON struct {
Code string `json:"code"`
Message string `json:"message"`
Blocking bool `json:"blocking,omitempty"`
Chapter int `json:"chapter,omitempty"` // 1-based; 0 = none
Line string `json:"line,omitempty"` // a story line's id
}
ProblemJSON is something that stops (Blocking) or affects a render.
type ProgressJSON ¶
type ProgressJSON struct {
Stage string `json:"stage,omitempty"`
Fraction float64 `json:"fraction"` // -1 = unknown
Message string `json:"message,omitempty"`
AudioSeconds float64 `json:"audio_seconds,omitempty"`
Bytes int64 `json:"bytes,omitempty"`
TotalBytes int64 `json:"total_bytes,omitempty"`
}
ProgressJSON is a running job's progress.
type ProjectJSON ¶
type ProjectJSON struct {
ID string `json:"id"`
Source string `json:"source"` // project, render, voice, take, export, dub, workflow, transcript, call
Category string `json:"category"` // the Projects page's filter
Title string `json:"title"`
Detail string `json:"detail,omitempty"`
Summary json.RawMessage `json:"summary,omitempty"` // a project's (model, chapters, lines, words, seconds…)
Updated time.Time `json:"updated"`
// Tool is the tool that opens it (get_longform, get_dub…).
Tool string `json:"tool,omitempty"`
}
ProjectJSON is an item of the project library.
type ProjectQuery ¶
type ProjectQuery struct {
Category string `json:"category,omitempty" jsonschema:"story, audiobook, dub, workflow, voice, transcript, take, export or call; empty: all."`
Search string `json:"search,omitempty" jsonschema:"Words in titles, scripts, names or paths."`
Limit int `json:"limit,omitempty" jsonschema:"At most this many (default 50, up to 500)."`
Offset int `json:"offset,omitempty" jsonschema:"Skip this many (paging)."`
}
ProjectQuery lists the project library.
type RefCheckJSON ¶
type RefCheckJSON struct {
Grade string `json:"grade"` // good, fine, needs_work
Seconds float64 `json:"seconds"`
SpeechSeconds float64 `json:"speech_seconds"`
Noisy bool `json:"noisy,omitempty"`
Hints []HintJSON `json:"hints,omitempty"`
Note string `json:"note,omitempty"`
}
RefCheckJSON is a reference's grade and what to do.
type RefCheckRequest ¶
type RefCheckRequest struct {
Path string `json:"path" jsonschema:"Absolute path of the recording (wav, mp3, m4a, mp4…)."`
Text string `json:"text,omitempty" jsonschema:"What it says, if known: a mismatch with what is heard is reported."`
}
RefCheckRequest grades a recording as a clone reference.
type RemovedModelJSON ¶
type RemovedModelJSON struct {
ID string `json:"id"`
Object string `json:"object"` // "model"
Label string `json:"label"`
Repo string `json:"repo"`
Removed bool `json:"removed"`
ReplacedBy string `json:"replaced_by"`
CloneReplacedBy string `json:"clone_replaced_by,omitempty"`
Warning string `json:"warning"`
}
RemovedModelJSON answers GET /v1/models/{id} for a model AudioSmith removed (thread #43): requests naming it are answered by ReplacedBy (CloneReplacedBy when they clone a voice), with a warning.
type RenderChapterOut ¶
type RenderChapterOut struct {
Title string `json:"title,omitempty"`
State string `json:"state"`
File string `json:"file,omitempty"`
Seconds float64 `json:"seconds,omitempty"`
Error string `json:"error,omitempty"`
}
RenderChapterOut is a chapter of a render.
type RenderJSON ¶
type RenderJSON struct {
ID string `json:"render_id"`
JobID string `json:"job_id"` // "longform:<render_id>"
State string `json:"state"` // running, done, failed, stopped
Partial bool `json:"partial,omitempty"`
Seconds float64 `json:"seconds,omitempty"`
Book string `json:"book,omitempty"` // the book as WAV
M4B string `json:"m4b,omitempty"`
Cues string `json:"cues,omitempty"`
Error string `json:"error,omitempty"`
Encode string `json:"encode_error,omitempty"`
Chapter []RenderChapterOut `json:"chapters,omitempty"`
Stems map[string]string `json:"stems,omitempty"` // character ("" = narrator) → WAV
Created time.Time `json:"created_at"`
}
RenderJSON is a render of a project.
type Replacement ¶
type Replacement struct {
Model string `json:"model"` // the removed model's id
ReplacedBy string `json:"replaced_by"` // the catalogue id that answered
Warning string `json:"warning"`
}
Replacement says a request named a model AudioSmith removed (thread #43) and which model answered instead.
type Route ¶
type Route struct {
Pattern string // "POST /v1/audio/speech"
Access string // "public", "consume", "admin"
}
Route is one route of the API, for the spec test and the settings page's endpoint list.
type SampleJSON ¶
type SampleJSON struct {
ID string `json:"sample_id"`
Kind string `json:"kind"` // story, audiobook, narration, dub, transcript
Title string `json:"title"`
Description string `json:"description"`
Available bool `json:"available"` // bundled in this build
Copy string `json:"copy,omitempty"` // the copy opened before ("<kind>:<id>")
}
SampleJSON is a sample project of Home's 示例 tab.
type SampleOpen ¶
type SampleOpen struct {
ID string `json:"sample_id" jsonschema:"A sample from list_samples: story, chapter, narration, dub or meeting."`
}
SampleOpen opens a sample.
type SampleOpened ¶
type SampleOpened struct {
ID string `json:"sample_id"`
Kind string `json:"kind"`
Ref string `json:"ref"` // "<kind>:<id>"
Tool string `json:"tool,omitempty"` // what reads it: get_longform project_id …
Files []string `json:"files,omitempty"`
}
SampleOpened is the copy a sample made in the library.
type SegmentJSON ¶
type SegmentJSON struct {
Start float64 `json:"start"`
End float64 `json:"end"`
Text string `json:"text"`
Speaker string `json:"speaker,omitempty"`
Words []WordJSON `json:"words,omitempty"`
}
SegmentJSON is a sentence of a transcript.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the Local API. Its handlers are goroutine-safe; Start and Stop are called by the app (one goroutine at a time).
func (*Server) CheckReference ¶
func (s *Server) CheckReference(ctx context.Context, req RefCheckRequest) (RefCheckJSON, error)
CheckReference grades a recording as a clone reference.
func (*Server) CloneVoice ¶
CloneVoice saves a voice cloned from a file (copied into the library).
func (*Server) CreateLongform ¶
func (s *Server) CreateLongform(ctx context.Context, req LongformCreate) (LongformJSON, error)
CreateLongform makes a Stories or Audiobook project.
func (*Server) DesignVoice ¶
DesignVoice saves a voice made from a description. The voice renders with design models as described; others clone its sample once the app renders one.
func (*Server) DetectWatermark ¶
DetectWatermark checks a file for AudioSmith's invisible watermark.
func (*Server) Direct ¶
Direct reads a performance note: emotions, an instruction, rate, pitch and energy.
func (*Server) DownloadModel ¶
DownloadModel queues a model's download and returns its job id.
func (*Server) DuplicateVoice ¶
DuplicateVoice copies a saved voice.
func (*Server) ExportLongform ¶
func (s *Server) ExportLongform(ctx context.Context, req LongformExport) (ExportJSON, error)
ExportLongform saves a finished render's files.
func (*Server) ExportTake ¶
func (s *Server) ExportTake(ctx context.Context, req TakeExport) (ExportJSON, error)
ExportTake writes a take with the Export audio dialog's options.
func (*Server) ExportTranscript ¶
func (s *Server) ExportTranscript(ctx context.Context, req TranscriptExport) (ExportJSON, error)
ExportTranscript writes a transcript as TXT, SRT, VTT or JSON.
func (*Server) ExportVoice ¶
func (s *Server) ExportVoice(ctx context.Context, req VoiceExportRequest) (ExportJSON, error)
ExportVoice writes a saved voice as an .asvoice file.
func (*Server) ImportVoice ¶
func (s *Server) ImportVoice(ctx context.Context, req VoiceImportRequest) (VoiceImported, error)
ImportVoice reads an .asvoice (or .ovsvoice) file into My voices.
func (*Server) Isolations ¶
func (s *Server) Isolations(ctx context.Context) ([]IsolationJSON, error)
Isolations lists the isolations.
func (*Server) Job ¶
Job is a job's state, after waiting up to wait (≤ MaxWait) for it to end; it answers as soon as it ends.
func (*Server) LANHandler ¶
LANHandler is the LAN listener's handler, for tests.
func (*Server) Languages ¶
func (s *Server) Languages(model string) ([]LanguageJSON, error)
Languages lists the languages of a model (catalogue id, repo or label), or of every speech model ("").
func (*Server) LastRequest ¶
LastRequest is when a client's request last passed the checks (zero: none since the start).
func (*Server) OpenSample ¶
OpenSample copies a sample into the library.
func (*Server) OutputDir ¶
OutputDir is where agents' files go unless they name a folder: the MCP folder of Settings → Local API (default <data>/mcp).
func (*Server) OutputFile ¶
OutputFile is the file an export writes: name (a file name only) with ext in dir (OutputFolder).
func (*Server) OutputFolder ¶
OutputFolder is the folder an export writes to: dir (absolute; made if missing), or the agents' folder for "".
func (*Server) Projects ¶
func (s *Server) Projects(ctx context.Context, q ProjectQuery) ([]ProjectJSON, error)
Projects lists the project library.
func (*Server) RenderLongform ¶
RenderLongform starts a render.
func (*Server) RenewPIN ¶
RenewPIN gives LAN sharing a new PIN and forgets the wrong attempts (the lock, the refused devices); the listener stays (ok false: sharing is off).
func (*Server) RunWorkflow ¶
RunWorkflow runs a saved workflow.
func (*Server) Samples ¶
func (s *Server) Samples(ctx context.Context) ([]SampleJSON, error)
Samples lists the sample projects.
func (*Server) SearchGallery ¶
func (s *Server) SearchGallery(ctx context.Context, q GalleryQuery) (GalleryPage, error)
SearchGallery searches Discover voices.
func (*Server) Start ¶
Start listens on 127.0.0.1:port (0 picks a free port, for tests). It stops a listener already running first.
func (*Server) StartIsolation ¶
func (s *Server) StartIsolation(ctx context.Context, req IsolateRequest) (IsolationJSON, error)
StartIsolation separates a file's voices from its music and effects.
func (*Server) StartLAN ¶
StartLAN opens the LAN listener on every interface at port with a new PIN, and returns how to reach it.
func (*Server) StartSpeech ¶
StartSpeech queues a speech request. Follow it with Wait.
func (*Server) Stop ¶
Stop closes every listener (requests in flight get a few seconds) and stops following jobs.
func (*Server) StopLAN ¶
func (s *Server) StopLAN()
StopLAN closes the LAN listener; the PIN is forgotten.
func (*Server) Transcribe ¶
func (s *Server) Transcribe(ctx context.Context, p TranscribeParams) (Transcription, error)
Transcribe transcribes a file through the queue and waits for it. The transcript is kept in the library (the Transcribe page lists it).
func (*Server) TranslateToEnglish ¶
func (s *Server) TranslateToEnglish(ctx context.Context, t core.Transcript) (core.Transcript, error)
TranslateToEnglish translates a transcript's segments into English with Settings → Writing help's language model (speech translation models are not in the catalogue yet). An English transcript is kept as it is.
func (*Server) UpdateLongform ¶
func (s *Server) UpdateLongform(ctx context.Context, req LongformUpdate) (LongformJSON, error)
UpdateLongform changes a project's voices and settings.
func (*Server) UpdateVoice ¶
UpdateVoice changes a saved voice's name, style, language, tags or reference text.
func (*Server) UseGalleryVoice ¶
UseGalleryVoice saves a gallery voice to the voice library.
func (*Server) VoicePreview ¶
func (s *Server) VoicePreview(ctx context.Context, q VoicePreviewQuery) (VoicePreview, error)
VoicePreview is a voice's preview clip: a saved voice's, a Discover voice's or a built-in speaker's.
func (*Server) Workflows ¶
func (s *Server) Workflows(ctx context.Context) ([]WorkflowJSON, error)
Workflows lists the saved workflows.
func (*Server) WriteStory ¶
func (s *Server) WriteStory(ctx context.Context, req StoryDraftRequest) (StoryDraftJSON, error)
WriteStory drafts a story with the writing help.
type Share ¶
type Share struct {
// Locked: wrong PINs from several devices stopped the PIN for
// everyone until Until (the key still works; RenewPIN ends it).
// wrong PINs or keys.
Limited int
// change pending): when to look again.
Next time.Time
}
Share describes LAN sharing for the UI.
type SkillSource ¶
type SkillSource interface {
// AgentSkill is a file of an agent's skill ("SKILL.md",
// "reference/tools.md") in the UI's language: *Error not_found for an
// unknown agent, invalid_request for an unknown file.
AgentSkill(ctx context.Context, agent, file string) (string, error)
}
SkillSource is implemented by backends that serve the agent skill of the Integrations page (the setup prompt downloads it). It never holds the API key.
type SpeakRequest ¶
type SpeakRequest struct {
ID string // the take's id (core.NewID)
Text string
Model catalog.Entry
// Voice is a saved voice to speak with; nil = none.
Voice *core.Voice
// Speaker is a built-in speaker of the model; "" = its default, or
// one of Gender when that is set.
Speaker string
Gender string // "female" | "male" | ""
// Instructions describe the delivery (instruct models), or the voice
// to design (design models without a saved voice).
Instructions string
// Language is BCP-47 or the model's own value; "" = the voice's.
Language string
// RefAudio / RefText clone from a clip without saving a voice.
RefAudio, RefText string
Speed, Temperature, TopP, Guidance, Exaggeration, Duration float64
Seed int64
Steps int
// Normalize applies "Even out volume" (mastering): off for API
// requests unless asked, so streamed audio equals the take.
Normalize bool
Bits int // 16 (0), 24, 32 (float)
// Client names the agent asking (MCP, X-AudioSmith-Client), "" when
// it did not say.
Client string
// Background queues behind interactive work.
Background bool
}
SpeakRequest is a speech request the API resolved: its model and voice are known.
type SpeakerJSON ¶
type SpeakerJSON struct {
ID string `json:"id"`
Language string `json:"language,omitempty"`
Gender string `json:"gender,omitempty"`
// An outside engine's character (thread #171): its name and style,
// the credit its audio carries and what its terms allow
// ("commercial", "individual", "noncommercial", "ask").
Name string `json:"name,omitempty"`
Style string `json:"style,omitempty"`
Credit string `json:"credit,omitempty"`
Use string `json:"use,omitempty"`
}
SpeakerJSON is a built-in speaker.
type SpecOperation ¶
type SpecOperation struct {
Method, Path, Summary, Tag string
}
SpecOperation is one operation of the spec, for the settings page.
func Operations ¶
func Operations() []SpecOperation
Operations lists the spec's operations in its order.
type Speech ¶
type Speech struct {
// Recipe is the take being made: model, voice and parameters as the
// engine gets them.
Recipe core.Take
Model catalog.Entry
JobID string
// VoiceName names the voice used, for headers and answers.
VoiceName string
// Ignored lists the parameters the model does not honour.
Ignored []string
// Replaced is set when the request named a removed model.
Replaced *Replacement
// contains filtered or unexported fields
}
Speech is a speech request in the queue.
func (*Speech) Cancel ¶
func (sp *Speech) Cancel()
Cancel cancels a speech request that is not waited for.
func (*Speech) Detach ¶
func (sp *Speech) Detach()
Detach stops following a speech request without cancelling it.
func (*Speech) Wait ¶
func (sp *Speech) Wait(ctx context.Context, onChunk func(proto.ChunkParams) error) (SpeechResult, error)
Wait follows the take until it is made. Chunks of audio (pcm16le, the take's rate) go to onChunk as they are made, when it is set. If ctx ends, the take is cancelled.
type SpeechParams ¶
type SpeechParams struct {
Text string
// Model: a catalogue id, repo or label, or one of OpenAI's names (the
// default model; "" too).
Model string
// Voice: a saved voice's id or name, a built-in speaker of the
// model, an OpenAI voice name, or "" (the client's bound voice, else
// the model's default).
Voice string
// Instructions: delivery (instruct models) or, on a design model
// without a saved voice, the voice to design.
Instructions string
Language string
Speed, Temperature, TopP, Guidance, Exaggeration, Duration float64
Seed int64
Steps int
Normalize bool
Bits int
// RefAudio (a readable path) clones without saving a voice.
RefAudio, RefText string
// Client is the agent asking (MCP, X-AudioSmith-Client): its bound
// voice and model apply when Voice and Model are empty.
Client string
Background bool
}
SpeechParams is a speech request as clients write it: models and voices by name. Zero values leave the model's defaults.
type SpeechResult ¶
type SpeechResult struct {
Take core.Take // the recipe and its result (the take is saved in the history)
// Output is the take's WAV file.
Output string
}
SpeechResult is a finished take.
type Status ¶
type Status struct {
// State: "ready", "starting", "restarting", "failed", "stopped".
State string `json:"state"`
// Detail says why it is not ready (English).
Detail string `json:"detail,omitempty"`
Version string `json:"version"` // the app's
EngineVersion string `json:"engineVersion,omitempty"` // the engine's
Device string `json:"device,omitempty"` // "Apple M4"
Memory int64 `json:"memory,omitempty"` // unified memory, bytes
// Families the engine can load; nil until it is ready.
Families []string `json:"families,omitempty"`
// Loaded are the repos of resident models.
Loaded []string `json:"loaded,omitempty"`
// RetryAfter is a hint, in seconds, while not ready (restart planned).
RetryAfter int `json:"-"`
}
Status is the engine's state for the API.
type StemJSON ¶
type StemJSON struct {
Name string `json:"name"` // vocals, background, clean
File string `json:"file"` // absolute path
About string `json:"about"`
}
StemJSON is a stem written.
type StoryCreate ¶
type StoryCreate struct {
Title string `json:"title,omitempty" jsonschema:"The story's title; empty: the file's."`
Path string `json:"path,omitempty" jsonschema:"Absolute path of a file to import: TXT, Markdown, EPUB, DOCX, SRT or VTT."`
Text string `` /* 200-byte string literal not displayed */
Lines []StoryLineIn `json:"lines,omitempty" jsonschema:"Or the lines as data, in order."`
Split string `` /* 133-byte string literal not displayed */
Model string `json:"model,omitempty" jsonschema:"A speech model id (list_models); empty: AudioSmith's default."`
Voice string `` /* 162-byte string literal not displayed */
Cast map[string]string `` /* 136-byte string literal not displayed */
Language string `json:"language,omitempty" jsonschema:"BCP-47 code of the text; empty: automatic."`
Format string `json:"format,omitempty" jsonschema:"wav (default) or m4b."`
}
StoryCreate is create_story's input.
func (StoryCreate) Longform ¶
func (in StoryCreate) Longform() LongformCreate
Longform is the request of a story's input.
type StoryDraftJSON ¶
type StoryDraftJSON struct {
Script string `json:"script"` // [voice:Name] lines, narration untagged
Title string `json:"title,omitempty"`
Project *LongformJSON `json:"project,omitempty"`
}
StoryDraftJSON is a draft and, with create, its project.
type StoryDraftRequest ¶
type StoryDraftRequest struct {
Description string `json:"description" jsonschema:"What the story is about, in one or two sentences, in the language it should be written in."`
Create bool `json:"create,omitempty" jsonschema:"true also makes the Stories project of the draft, cast with voices (as the page does)."`
Model string `json:"model,omitempty" jsonschema:"With create: the speech model (list_models); empty: AudioSmith's default."`
}
StoryDraftRequest asks the writing help for a story script (Stories' 「帮我写」).
type StoryLineIn ¶
type StoryLineIn struct {
Text string `json:"text" jsonschema:"What is said (script markup works: [pause 500ms], tone tags); for a chapter line, its title."`
Speaker string `json:"speaker,omitempty" jsonschema:"The character who says it (a name; the cast gives it a voice); empty: the narrator."`
Voice string `json:"voice,omitempty" jsonschema:"A voice for this line only (a saved voice's name or id, or a built-in speaker)."`
Speed float64 `json:"speed,omitempty" jsonschema:"0.5–2; 0: the story's."`
PauseAfter int `json:"pause_after_ms,omitempty" jsonschema:"Silence after the line, in milliseconds (0: the usual gap)."`
Chapter bool `json:"chapter,omitempty" jsonschema:"true: the line starts a chapter titled text."`
}
StoryLineIn is a line of a story given as data.
type StoryLineJSON ¶
type StoryLineJSON struct {
ID string `json:"id"`
Text string `json:"text"`
Speaker string `json:"speaker,omitempty"`
Voice string `json:"voice,omitempty"`
Speed float64 `json:"speed,omitempty"`
PauseAfter int `json:"pause_after_ms,omitempty"`
Chapter bool `json:"chapter,omitempty"`
Direction string `json:"direction,omitempty"` // how the line is said (never spoken)
Intensity int `json:"intensity,omitempty"` // of the direction: 1 restrained, 2 clear, 3 strong; with an emotion 0–3
Emotion string `json:"emotion,omitempty"` // the AI director's emotion of the line (steady, happy, hurt…)
Turn bool `json:"turn,omitempty"` // a turn of the scene: its feeling may change at once
}
StoryLineJSON is a line of a story.
type Studio ¶
type Studio interface {
// Projects lists the project library (the Projects page).
Projects(ctx context.Context, q ProjectQuery) ([]ProjectJSON, error)
// CreateLongform makes and saves a Stories or Audiobook project.
CreateLongform(ctx context.Context, req LongformCreate) (LongformJSON, error)
Longform(ctx context.Context, id string) (LongformJSON, error)
// UpdateLongform changes a project's voices and settings.
UpdateLongform(ctx context.Context, req LongformUpdate) (LongformJSON, error)
// RenderLongform starts a render: job "longform:<render id>".
RenderLongform(ctx context.Context, req LongformRender) (JobJSON, error)
// ExportLongform copies or encodes a finished render's files into
// req.Dir (already checked: absolute, created).
ExportLongform(ctx context.Context, req LongformExport) (ExportJSON, error)
CreateDub(ctx context.Context, req DubCreate) (DubJSON, error)
Dub(ctx context.Context, req DubQuery) (DubJSON, error)
// RunDub runs the pipeline: job "dub:<id>".
RunDub(ctx context.Context, req DubRun) (JobJSON, error)
EditDub(ctx context.Context, req DubEdit) (DubJSON, error)
// ExportDub queues an export: a queue job (req.Output already checked).
ExportDub(ctx context.Context, req DubExport) (JobJSON, error)
BatchDub(ctx context.Context, req BatchRequest) (BatchJSON, error)
Batch(ctx context.Context) (BatchJSON, error)
SearchGallery(ctx context.Context, q GalleryQuery) (GalleryPage, error)
// UseGalleryVoice saves an archetype as a designed voice, as the
// gallery's "Use voice" does (once: a second use finds it).
UseGalleryVoice(ctx context.Context, id string) (GalleryUse, error)
// ExportTake writes a take with the Export audio dialog's options
// (req.Output already checked).
ExportTake(ctx context.Context, req TakeExport) (ExportJSON, error)
Workflows(ctx context.Context) ([]WorkflowJSON, error)
// RunWorkflow runs a saved workflow: job "workflow:<id>".
RunWorkflow(ctx context.Context, req WorkflowRun) (JobJSON, error)
// Task is a group job's state (ids with a GroupPrefixes prefix);
// CancelTask stops it.
Task(ctx context.Context, id string) (JobJSON, error)
CancelTask(ctx context.Context, id string) error
// Delete deletes a Stories or Audiobook project (kind "project") or a
// dub ("dub"). Callers checked the confirmation.
Delete(ctx context.Context, kind, id string) error
}
Studio is what the app offers agents beyond speech and transcription. Every method is goroutine-safe. A Backend that also implements Studio enables the routes and tools of this file; without it they answer 501 unsupported.
type TakeExport ¶
type TakeExport struct {
ID string `json:"take_id" jsonschema:"The take (generate_speech's take_id, or list_takes)."`
Format string `json:"format,omitempty" jsonschema:"wav (default), m4a, mp3, flac or opus (mp3, flac and opus need ffmpeg; m4a the engine)."`
Bits int `json:"bits,omitempty" jsonschema:"wav: 16, 24 or 32 (float); flac: 16 or 24. Default 24 (wav), 16 (flac)."`
Bitrate int `json:"bitrate_kbps,omitempty" jsonschema:"m4a 128/192/256, mp3 128/192/320, opus 64/96/128; 0: the format's default."`
SampleRate int `json:"sample_rate,omitempty" jsonschema:"44100 or 48000; 0: the take's (opus is always 48000)."`
Channels int `json:"channels,omitempty" jsonschema:"1 (mono) or 2 (stereo); 0: the take's."`
Loudness string `json:"loudness,omitempty" jsonschema:"podcast (−16 LUFS), speech (−18 LUFS), broadcast (−23 LUFS) or off (default)."`
Trim bool `json:"trim,omitempty" jsonschema:"Trim leading and trailing silence."`
Title string `json:"title,omitempty" jsonschema:"Title tag (not wav)."`
Artist string `json:"artist,omitempty" jsonschema:"Artist tag (not wav)."`
Script bool `json:"script,omitempty" jsonschema:"Also save the text beside it (.txt)."`
Subtitles bool `json:"subtitles,omitempty" jsonschema:"Also save subtitles beside it (.srt), timed to the audio."`
Dir string `json:"directory,omitempty" jsonschema:"Absolute folder to write to; empty: AudioSmith's agents' folder."`
Filename string `json:"filename,omitempty" jsonschema:"The file's name (no folders); empty: from the text."`
Output string `json:"-"`
}
TakeExport writes a take with the Export audio dialog's options.
type TakeJSON ¶
type TakeJSON struct {
ID string `json:"id"`
Object string `json:"object"` // "take"
CreatedAt time.Time `json:"created_at"`
Text string `json:"text"`
Model string `json:"model"`
ModelID string `json:"model_id,omitempty"` // catalogue id
Voice string `json:"voice,omitempty"` // what the engine got (speaker, design tags…)
VoiceID string `json:"voice_id,omitempty"`
Language string `json:"language,omitempty"`
Speed float64 `json:"speed,omitempty"`
Seed int64 `json:"seed,omitempty"`
Duration float64 `json:"duration,omitempty"`
Steps int `json:"steps,omitempty"`
SampleRate int `json:"sample_rate"`
AudioSeconds float64 `json:"audio_seconds"`
GenSeconds float64 `json:"gen_seconds"`
RTF float64 `json:"rtf,omitempty"`
Starred bool `json:"starred,omitempty"`
ProjectID string `json:"project_id,omitempty"`
JobID string `json:"job_id,omitempty"`
AudioURL string `json:"audio_url"`
// Credit is the attribution the audio must carry when published (a
// VOICEVOX character's, thread #171).
Credit string `json:"credit,omitempty"`
}
TakeJSON is a take of the history.
type Toolkit ¶
type Toolkit interface {
// StartIsolation queues an isolation of a media file (job owner
// "isolate:<id>"); core.ErrNotDownloaded without the separator.
StartIsolation(ctx context.Context, path string) (IsolationJSON, error)
// Isolations lists the isolations, newest first; Isolation reads one.
Isolations(ctx context.Context) ([]IsolationJSON, error)
Isolation(ctx context.Context, id string) (IsolationJSON, error)
DeleteIsolation(ctx context.Context, id string) error
// Assets lists every output and imported file, newest first
// (q.Limit and q.Offset already bounded).
Assets(ctx context.Context, q AssetQuery) ([]AssetJSON, error)
// Samples lists the sample projects; OpenSample copies one into the
// library (a new copy each time) and says where.
Samples(ctx context.Context) ([]SampleJSON, error)
OpenSample(ctx context.Context, id string) (SampleOpened, error)
// UpdateVoice, DuplicateVoice, ExportVoice (req.Dir checked) and
// ImportVoice (path checked) manage the voice library as My voices'
// menu does; VoicePreview is a voice's preview clip.
UpdateVoice(ctx context.Context, req VoiceUpdate) (core.Voice, error)
DuplicateVoice(ctx context.Context, req VoiceDuplicate) (core.Voice, error)
ExportVoice(ctx context.Context, req VoiceExportRequest) (ExportJSON, error)
ImportVoice(ctx context.Context, path string) (VoiceImported, error)
VoicePreview(ctx context.Context, q VoicePreviewQuery) (VoicePreview, error)
// CheckReference grades a recording (path checked) as a clone
// reference, as Quick clone's checker does.
CheckReference(ctx context.Context, req RefCheckRequest) (RefCheckJSON, error)
// WriteStory drafts a story with the writing help's language model
// (llm_unavailable without one) and, if asked, makes its project.
WriteStory(ctx context.Context, req StoryDraftRequest) (StoryDraftJSON, error)
}
Toolkit is implemented by backends that offer the toolkit; without it its routes and tools answer 501 unsupported. Every method is goroutine-safe; arguments are checked (paths resolved, ids not empty).
type TranscribeParams ¶
type TranscribeParams struct {
// File is a readable path; it is not removed (uploads are, by the
// handlers that saved them).
File string
Title string
// Model: a catalogue id, repo or label, or OpenAI's names.
Model string
Language string // BCP-47; "" detects it
Prompt string
// Words asks for word timings (the forced aligner runs when the model
// gives none).
Words bool
// Speakers asks who says what: the speakers model (thread #48,
// MOSS-Transcribe-Diarize) transcribes, whatever Model says, and the
// segments carry speaker labels. Naming that model, or OpenAI's
// gpt-4o-transcribe-diarize, does the same.
Speakers bool
}
TranscribeParams is a transcription as clients ask for it.
type TranscriptExport ¶
type TranscriptExport struct {
ID string `json:"transcript_id" jsonschema:"The transcript's id (transcribe returns it; GET /api/transcripts lists them)."`
Format string `json:"format,omitempty" jsonschema:"txt (default), srt, vtt or json."`
Dir string `json:"directory,omitempty" jsonschema:"Absolute folder to write to; empty: AudioSmith's agents' folder."`
Filename string `json:"filename,omitempty" jsonschema:"The file's name (no folders); empty: from the transcript's title."`
}
TranscriptExport writes a transcript as a file.
type TranscriptJSON ¶
type TranscriptJSON struct {
ID string `json:"id"`
Object string `json:"object"` // "transcript"
CreatedAt time.Time `json:"created_at"`
Title string `json:"title,omitempty"`
Source string `json:"source"`
Model string `json:"model"`
Language string `json:"language,omitempty"`
Duration float64 `json:"duration"`
Text string `json:"text"`
Clean string `json:"clean,omitempty"`
// Speakers names speaker labels ("S1" → "Ana") the user named.
Speakers map[string]string `json:"speakers,omitempty"`
Segments []SegmentJSON `json:"segments,omitempty"`
}
TranscriptJSON is a transcript.
type Transcription ¶
type Transcription struct {
Transcript core.Transcript
Warnings []string
// Replaced is set when the request named a removed model.
Replaced *Replacement
}
Transcription is a finished transcript.
type VoiceDuplicate ¶
type VoiceDuplicate struct {
ID string `json:"voice_id" jsonschema:"The saved voice to copy (id or name)."`
Name string `json:"name,omitempty" jsonschema:"The copy's name; empty: '<name> (copy)'."`
}
VoiceDuplicate copies a saved voice.
type VoiceExportRequest ¶
type VoiceExportRequest struct {
ID string `json:"voice_id" jsonschema:"The saved voice (id or name)."`
IncludeReference bool `` /* 155-byte string literal not displayed */
Licence string `json:"licence,omitempty" jsonschema:"An SPDX licence id for the file (CC-BY-4.0…); empty: personal use."`
Dir string `json:"directory,omitempty" jsonschema:"Absolute folder to write to; empty: AudioSmith's agents' folder."`
Filename string `json:"filename,omitempty" jsonschema:"The file's name (no folders; .asvoice is added); empty: the voice's name."`
}
VoiceExportRequest writes a .asvoice file.
type VoiceImportRequest ¶
type VoiceImportRequest struct {
Path string `json:"path" jsonschema:"Absolute path of an .asvoice (or VoiceStudio .ovsvoice) file."`
}
VoiceImportRequest reads a voice file.
type VoiceImported ¶
type VoiceImported struct {
Voice VoiceJSON `json:"voice"`
Warnings []string `json:"warnings,omitempty"`
}
VoiceImported is a voice an import saved.
type VoiceJSON ¶
type VoiceJSON struct {
ID string `json:"id"`
Object string `json:"object"` // "voice"
Name string `json:"name"`
Kind string `json:"kind"` // "cloned" | "designed" | "builtin"
Model string `json:"model,omitempty"` // repo it is for; "" = any model that can
Speaker string `json:"speaker,omitempty"`
Language string `json:"language,omitempty"`
Style string `json:"style,omitempty"`
Design string `json:"design,omitempty"`
Seed int64 `json:"seed,omitempty"`
RefText string `json:"ref_text,omitempty"`
RefSeconds float64 `json:"ref_seconds,omitempty"`
Locked bool `json:"locked,omitempty"`
Verified bool `json:"verified,omitempty"`
Tags []string `json:"tags,omitempty"`
Origin string `json:"origin,omitempty"`
HasAudio bool `json:"has_audio"` // GET /api/voices/{id}/audio plays a sample or the reference
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
VoiceJSON is a saved voice.
type VoicePreview ¶
type VoicePreview struct {
Data []byte `json:"-"`
MIME string `json:"mime"` // audio/ogg, audio/wav
Ext string `json:"-"` // "ogg", "wav"
Name string `json:"name"`
Text string `json:"text,omitempty"` // what it says, when known
Model string `json:"model,omitempty"`
}
VoicePreview is a preview clip: its bytes and type, and what it is.
type VoicePreviewQuery ¶
type VoicePreviewQuery struct {
VoiceID string `json:"voice_id,omitempty" jsonschema:"A saved voice (id or name): the start of its sample or reference."`
Gallery string `json:"gallery_id,omitempty" jsonschema:"Or a Discover voice's id (search_voices): its bundled preview."`
Model string `json:"model,omitempty" jsonschema:"Or a model id with speaker: that built-in speaker's bundled preview."`
Speaker string `json:"speaker,omitempty" jsonschema:"A built-in speaker of model (list_models → voices)."`
Output string `` /* 147-byte string literal not displayed */
}
VoicePreviewQuery asks for a voice's preview clip.
type VoiceUpdate ¶
type VoiceUpdate struct {
ID string `json:"voice_id" jsonschema:"The saved voice (id or name, see list_voices)."`
Name string `json:"name,omitempty" jsonschema:"A new name (one line, up to 80 characters)."`
Style string `json:"style,omitempty" jsonschema:"A delivery hint kept with the voice (calm, whisper…)."`
Language string `json:"language,omitempty" jsonschema:"The speaker's language (BCP-47)."`
RefText string `json:"ref_text,omitempty" jsonschema:"What the voice's reference recording says (cloned voices)."`
Tags *[]string `json:"tags,omitempty" jsonschema:"Its tags, replacing the old ones ([] clears them)."`
}
VoiceUpdate changes a saved voice's details; empty fields stay.
type WatchFolderJSON ¶
type WatchFolderJSON struct {
Folder string `json:"folder,omitempty"`
Active bool `json:"active"`
Paused bool `json:"paused,omitempty"`
Added int `json:"added"`
Error string `json:"error,omitempty"`
}
WatchFolderJSON is the Batch page's watch folder (read only).
type WatermarkReport ¶
type WatermarkReport struct {
proto.WatermarkDetectResult
// AudioSmith: the mark is AudioSmith's (its marker byte, decoded with
// confidence); Install is then the install id that made it.
AudioSmith bool `json:"audioSmith"`
Install int `json:"install,omitempty"`
}
WatermarkReport is the detection with the message read as AudioSmith's.
type WatermarkRequest ¶
type WatermarkRequest struct {
Path string `json:"path" jsonschema:"Absolute path of the audio file to check."`
}
WatermarkRequest checks a file for the watermark.
type WordJSON ¶
type WordJSON struct {
Word string `json:"word"`
Start float64 `json:"start"`
End float64 `json:"end"`
}
WordJSON is a timed word (OpenAI's shape).
type WorkflowJSON ¶
type WorkflowJSON struct {
ID string `json:"workflow_id"`
Name string `json:"name"`
Steps string `json:"steps"` // "start → speak → export"
Input string `json:"input"` // "scripts" or "files"
Scripts []string `json:"scripts,omitempty"`
Files []string `json:"files,omitempty"`
Exports []string `json:"export_folders,omitempty"`
LastRun *WorkflowRunOut `json:"last_run,omitempty"`
JobID string `json:"job_id"` // "workflow:<id>"
Problem []string `json:"problems,omitempty"`
Updated time.Time `json:"updated_at"`
}
WorkflowJSON is a saved workflow and its inputs.
type WorkflowRun ¶
type WorkflowRun struct {
ID string `json:"workflow_id" jsonschema:"The workflow (list_workflows)."`
Scripts []string `` /* 142-byte string literal not displayed */
Files []string `` /* 135-byte string literal not displayed */
Again bool `json:"again,omitempty" jsonschema:"Make every result anew (default: keep results whose inputs did not change)."`
}
WorkflowRun runs a saved workflow.
type WorkflowRunOut ¶
type WorkflowRunOut struct {
State string `json:"state"`
Items int `json:"items"`
Done int `json:"done"`
}
WorkflowRunOut sums up a run.
Source Files
¶
- audio.go
- auth.go
- backend.go
- bodydeadline.go
- errors.go
- health.go
- json.go
- kit.go
- kit_http.go
- kit_types.go
- native.go
- native_models.go
- native_takes.go
- openai.go
- openai_models.go
- openai_transcribe.go
- openapi.go
- pinguard.go
- resolve.go
- routes.go
- server.go
- speech.go
- sse.go
- studio.go
- studio_http.go
- studio_ops.go
- studio_types.go
- studio_types_dub.go
- studio_types_longform.go
- transcribe.go
- watch.go
- watermark.go
- ws.go