| | |
| | | Close() |
| | | } |
| | | |
| | | // ProviderEngine is implemented by engines that can report the concrete |
| | | // sherpa/onnxruntime provider selected at initialization time. |
| | | type ProviderEngine interface { |
| | | Provider() string |
| | | } |
| | | |
| | | // StreamingEngine is implemented by engines that can expose partial results |
| | | // while audio is still being captured. |
| | | type StreamingEngine interface { |
| | |
| | | cfg, err := config.Load() |
| | | if err != nil { |
| | | logger.Error("Failed to load config for model selection: %v", err) |
| | | cfg = config.Default() |
| | | cfg = config.ExistingConfigFallback() |
| | | } |
| | | current := modelselection.Resolve(cfg, language.NewSystemDetector()) |
| | | return NewWithModelID(current.ModelID) |
| | |
| | | return newPlatformEngine(resolved) |
| | | } |
| | | |
| | | func audioDurationMS(samples []float32) int64 { |
| | | return int64(len(samples)) * 1000 / 16000 |
| | | } |
| | | |
| | | func durationMS(duration time.Duration) int64 { |
| | | return duration.Milliseconds() |
| | | } |
| | | |
| | | func isSupportedBackend(backend string) bool { |
| | | switch backend { |
| | | case model.BackendSenseVoice, model.BackendMoonshine, model.BackendTransducer, model.BackendNemoTransducer, model.BackendQwen3ASR, model.BackendXASRStreaming: |
| | |
| | | func resolveCurrentModel() (model.ResolvedModel, error) { |
| | | cfg, err := config.Load() |
| | | if err != nil { |
| | | cfg = config.Default() |
| | | cfg = config.ExistingConfigFallback() |
| | | } |
| | | current := modelselection.Resolve(cfg, language.NewSystemDetector()) |
| | | return model.ResolveModel(current.ModelID) |