provision

package
v1.156.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

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

View Source
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

func DownloadArchive(ctx context.Context, url, dest string, minBytes int64) error

DownloadArchive fetches url to dest atomically, rejecting bodies smaller than minBytes (error pages served with status 200).

func ExtractTarBz2

func ExtractTarBz2(archive, destDir string) error

ExtractTarBz2 decompresses and unpacks a .tar.bz2 file into destDir.

func FindLibDir

func FindLibDir(bin string) string

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

func LibPathEnv(libDir string) []string

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

func ProvisionArchive(ctx context.Context, url, targetDir string, minBytes int64) error

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

func SherpaAsset(goos, goarch string) (string, bool)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL