Ariver
2026-06-02 3fbceec8de833416bf1ae049f959f222c3f1a4a0
privatevoice.src/services/engine_service.go
File was renamed from VoiceSnapGo/services/engine_service.go
@@ -1,6 +1,7 @@
package services
import (
   "sync"
   "voicesnap/internal/engine"
   "voicesnap/internal/model"
   "voicesnap/internal/paths"
@@ -12,10 +13,14 @@
type EngineService struct {
   app          *application.App
   initCallback func()
   mu           sync.RWMutex
   status       string
   hardwareInfo string
   lastError    string
}
func NewEngineService() *EngineService {
   return &EngineService{}
   return &EngineService{status: "loading"}
}
// ModelExists returns true if the ASR model files are present.
@@ -23,6 +28,24 @@
   return engine.ModelExists()
}
func (s *EngineService) GetStatus() map[string]interface{} {
   s.mu.RLock()
   defer s.mu.RUnlock()
   return map[string]interface{}{
      "status":       s.status,
      "hardwareInfo": s.hardwareInfo,
      "error":        s.lastError,
   }
}
func (s *EngineService) SetStatus(status, hardwareInfo, lastError string) {
   s.mu.Lock()
   defer s.mu.Unlock()
   s.status = status
   s.hardwareInfo = hardwareInfo
   s.lastError = lastError
}
// DownloadModel downloads the ASR model with progress events.
func (s *EngineService) DownloadModel(primaryURL, fallbackURL string) error {
   err := model.Download(primaryURL, fallbackURL, paths.ModelsRoot(), func(percent float64, downloaded, total int64) {