Documentation
¶
Overview ¶
* ChatCLI - Shared self-provisioning helpers for embedded audio engines. * Copyright (c) 2024 Edilson Freitas * License: Apache-2.0 * * The embedded TTS (Kokoro) and embedded STT (Whisper) providers ship nothing * in the chatcli binary (the release is a CGO-free cross-compile): on first * use they download a prebuilt sherpa-onnx CLI plus a model archive into the * user cache and shell out. This package holds the provider-agnostic pieces: * the pinned sherpa-onnx release, atomic download + tar.bz2 extraction with * traversal/bomb guards, and the loader-path environment for the extracted * shared libraries. Downloads are atomic — fetch to a .part file, extract * into a .tmp directory, rename into place — so a crash mid-provision never * yields a half cache that masquerades as a working install.
Index ¶
- Constants
- func DownloadArchive(ctx context.Context, url, dest string, minBytes int64) error
- func ExtractTarBz2(archive, destDir string) error
- func FindLibDir(bin string) string
- func LibPathEnv(libDir string) []string
- func ProvisionArchive(ctx context.Context, url, targetDir string, minBytes int64) error
- func SherpaAsset(goos, goarch string) (string, bool)
Constants ¶
const ( // SherpaVersion pins the upstream release providing the prebuilt CLIs. // Model assets referenced by the embedded providers track this version; // bump them together. SherpaVersion = "1.13.2" // SherpaReleaseBase is the download URL prefix for the pinned release. SherpaReleaseBase = "https://github.com/k2-fsa/sherpa-onnx/releases/download/v" + SherpaVersion + "/" // Timeout covers a model download on slow links. Timeout = 30 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func DownloadArchive ¶
DownloadArchive fetches url to dest atomically, rejecting bodies smaller than minBytes (error pages served with status 200).
func ExtractTarBz2 ¶
ExtractTarBz2 decompresses and unpacks a .tar.bz2 file into destDir.
func FindLibDir ¶
FindLibDir resolves the shared-library directory for an extracted engine binary: the upstream tarball puts libraries in lib/ next to bin/; fall back to the binary's own directory.
func LibPathEnv ¶
LibPathEnv returns the process environment with the engine's shared-library directory prepended to the platform's loader path. The upstream binaries carry an rpath, so this is a belt-and-suspenders for stripped environments.
func ProvisionArchive ¶
ProvisionArchive downloads url and extracts it into targetDir atomically: the tarball lands next to targetDir as a temp file, extraction happens in targetDir.tmp, and only a fully extracted tree is renamed into place.
func SherpaAsset ¶
SherpaAsset maps GOOS/GOARCH to the upstream shared-build tarball name. Shared builds are ~25MB versus ~200MB+ for static ones; the libraries ride in the same tarball so the result is still self-contained.
Types ¶
This section is empty.