model

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package model은 음성 모델의 기대값과 캐시 위치를 정한다.

받고 검증하는 일은 루트 모듈의 internal/modelfetch 가 한다. 이 패키지는 그 기계에 whisper 와 화자 분할 모델이라는 값을 먹인다. 크기와 체크섬을 고정하는 규율, Range 이어받기, 오프라인 반입은 engram 본체의 모델과 같은 것을 쓴다(ADR 0080).

Index

Constants

View Source
const (
	EncoderName = "encoder.int8.onnx"
	DecoderName = "decoder.int8.onnx"
	TokensName  = "tokens.txt"
	SegmentName = "segmentation.onnx"
	SpeakerName = "speaker-embedding.onnx"
	VadName     = "silero_vad.onnx"
)

모델 디렉토리 안에 놓이는 파일 이름이다. 크기마다 디렉토리가 다르므로 이름에 크기를 넣지 않는다. 쓰는 쪽 코드가 크기를 몰라도 된다.

View Source
const Default = Large

Default는 기본 크기다.

View Source
const EnvModelDir = "ENGRAM_MODEL_DIR"

EnvModelDir는 모델 디렉토리를 바꾸는 환경변수다. engram 본체와 같은 이름을 쓴다. 사용자가 모델을 한 곳에 모으고 싶어 할 때 변수를 둘 기억하게 하지 않는다.

Variables

View Source
var ErrUnknownSize = errors.New("모르는 모델 크기")

ErrUnknownSize는 모르는 크기를 받았을 때의 오류다.

Functions

func Dir

func Dir(size Size) (string, error)

Dir는 크기별 모델 디렉토리를 낸다. ENGRAM_MODEL_DIR 이 있으면 그 아래에, 없으면 사용자 캐시 아래에 둔다. whisper 크기마다 디렉토리를 나누는 이유는 large-v3 와 medium 의 파일 이름이 접두사만 다르고 화자 분할 모델은 같아서, 한 디렉토리에 섞으면 어느 크기가 온전한지 판정할 수 없기 때문이다.

func TotalSize

func TotalSize(size Size) (int64, error)

TotalSize는 크기 하나를 받는 데 필요한 바이트 합계다. 사용자에게 얼마나 받는지 미리 알린다.

Types

type FileStatus

type FileStatus = modelfetch.FileStatus

ModelFile과 FileStatus와 ProgressFn은 modelfetch 의 것을 그대로 쓴다.

type ModelFile

type ModelFile = modelfetch.ModelFile

ModelFile과 FileStatus와 ProgressFn은 modelfetch 의 것을 그대로 쓴다.

func Files

func Files(size Size) ([]ModelFile, error)

Files는 크기 하나를 쓰는 데 필요한 파일 전부를 낸다. whisper 셋과 화자 분할 둘과 VAD 하나로 여섯이다.

type ProgressFn

type ProgressFn = modelfetch.ProgressFn

ModelFile과 FileStatus와 ProgressFn은 modelfetch 의 것을 그대로 쓴다.

type Size

type Size string

Size는 whisper 모델의 크기 갈래다.

const (
	Large  Size = "large-v3"
	Medium Size = "medium"
	Small  Size = "small"
)

고를 수 있는 크기 셋이다. 기본은 Large 다. 실제 한국어 회의 녹음 둘에서 기준 일치율이 medium 보다 12%p 높았다(ADR 0081).

func ParseSize

func ParseSize(s string) (Size, error)

ParseSize는 문자열을 크기로 바꾼다. 허용값이 아니면 에러다. 조용히 기본값으로 떨어지지 않는다. 오타를 낸 사용자가 왜 다른 모델이 도는지 모르게 된다.

func Sizes

func Sizes() []Size

Sizes는 고를 수 있는 크기를 고정 순서로 낸다.

Jump to

Keyboard shortcuts

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