mirror of
https://github.com/rishikanthc/Scriberr.git
synced 2026-03-03 03:57:01 +00:00
always copy scripts
This commit is contained in:
@@ -168,6 +168,11 @@ func (c *CanaryAdapter) GetSupportedModels() []string {
|
||||
func (c *CanaryAdapter) PrepareEnvironment(ctx context.Context) error {
|
||||
logger.Info("Preparing NVIDIA Canary environment", "env_path", c.envPath)
|
||||
|
||||
// Copy transcription script
|
||||
if err := c.copyTranscriptionScript(); err != nil {
|
||||
return fmt.Errorf("failed to copy transcription script: %w", err)
|
||||
}
|
||||
|
||||
// Check if environment is already ready (using cache to speed up repeated checks)
|
||||
if CheckEnvironmentReady(c.envPath, "import nemo.collections.asr") {
|
||||
modelPath := filepath.Join(c.envPath, "canary-1b-v2.nemo")
|
||||
@@ -188,11 +193,6 @@ func (c *CanaryAdapter) PrepareEnvironment(ctx context.Context) error {
|
||||
return fmt.Errorf("failed to download Canary model: %w", err)
|
||||
}
|
||||
|
||||
// Create transcription script
|
||||
if err := c.copyTranscriptionScript(); err != nil {
|
||||
return fmt.Errorf("failed to create transcription script: %w", err)
|
||||
}
|
||||
|
||||
c.initialized = true
|
||||
logger.Info("Canary environment prepared successfully")
|
||||
return nil
|
||||
|
||||
@@ -125,6 +125,15 @@ func (p *ParakeetAdapter) GetSupportedModels() []string {
|
||||
func (p *ParakeetAdapter) PrepareEnvironment(ctx context.Context) error {
|
||||
logger.Info("Preparing NVIDIA Parakeet environment", "env_path", p.envPath)
|
||||
|
||||
// Copy transcription scripts (standard and buffered)
|
||||
if err := p.copyTranscriptionScript(); err != nil {
|
||||
return fmt.Errorf("failed to copy transcription script: %w", err)
|
||||
}
|
||||
|
||||
if err := p.copyBufferedScript(); err != nil {
|
||||
return fmt.Errorf("failed to create buffered script: %w", err)
|
||||
}
|
||||
|
||||
// Check if environment is already ready (using cache to speed up repeated checks)
|
||||
if CheckEnvironmentReady(p.envPath, "import nemo.collections.asr") {
|
||||
modelPath := filepath.Join(p.envPath, "parakeet-tdt-0.6b-v3.nemo")
|
||||
@@ -159,15 +168,6 @@ func (p *ParakeetAdapter) PrepareEnvironment(ctx context.Context) error {
|
||||
return fmt.Errorf("failed to download Parakeet model: %w", err)
|
||||
}
|
||||
|
||||
// Create transcription scripts (standard and buffered)
|
||||
if err := p.copyTranscriptionScript(); err != nil {
|
||||
return fmt.Errorf("failed to create transcription script: %w", err)
|
||||
}
|
||||
|
||||
if err := p.createBufferedScript(); err != nil {
|
||||
return fmt.Errorf("failed to create buffered script: %w", err)
|
||||
}
|
||||
|
||||
p.initialized = true
|
||||
logger.Info("Parakeet environment prepared successfully")
|
||||
return nil
|
||||
@@ -557,8 +557,8 @@ func (p *ParakeetAdapter) parseResult(tempDir string, input interfaces.AudioInpu
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// createBufferedScript creates the Python script for NeMo buffered inference
|
||||
func (p *ParakeetAdapter) createBufferedScript() error {
|
||||
// copyBufferedScript creates the Python script for NeMo buffered inference
|
||||
func (p *ParakeetAdapter) copyBufferedScript() error {
|
||||
scriptContent, err := nvidiaScripts.ReadFile("py/nvidia/parakeet_transcribe_buffered.py")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read embedded transcribe_buffered.py: %w", err)
|
||||
|
||||
@@ -182,6 +182,11 @@ func (p *PyAnnoteAdapter) GetMinSpeakers() int {
|
||||
func (p *PyAnnoteAdapter) PrepareEnvironment(ctx context.Context) error {
|
||||
logger.Info("Preparing PyAnnote environment", "env_path", p.envPath)
|
||||
|
||||
// Always ensure diarization script exists
|
||||
if err := p.copyDiarizationScript(); err != nil {
|
||||
return fmt.Errorf("failed to create diarization script: %w", err)
|
||||
}
|
||||
|
||||
// Check if PyAnnote is already available (using cache to speed up repeated checks)
|
||||
if CheckEnvironmentReady(p.envPath, "from pyannote.audio import Pipeline") {
|
||||
logger.Info("PyAnnote already available in environment")
|
||||
@@ -198,11 +203,6 @@ func (p *PyAnnoteAdapter) PrepareEnvironment(ctx context.Context) error {
|
||||
return fmt.Errorf("failed to setup PyAnnote environment: %w", err)
|
||||
}
|
||||
|
||||
// Always ensure diarization script exists
|
||||
if err := p.copyDiarizationScript(); err != nil {
|
||||
return fmt.Errorf("failed to create diarization script: %w", err)
|
||||
}
|
||||
|
||||
// Verify PyAnnote is now available
|
||||
testCmd := exec.Command("uv", "run", "--native-tls", "--project", p.envPath, "python", "-c", "from pyannote.audio import Pipeline")
|
||||
if testCmd.Run() != nil {
|
||||
|
||||
@@ -152,6 +152,11 @@ func (s *SortformerAdapter) GetMinSpeakers() int {
|
||||
func (s *SortformerAdapter) PrepareEnvironment(ctx context.Context) error {
|
||||
logger.Info("Preparing NVIDIA Sortformer environment", "env_path", s.envPath)
|
||||
|
||||
// Copy diarization script
|
||||
if err := s.copyDiarizationScript(); err != nil {
|
||||
return fmt.Errorf("failed to copy diarization script: %w", err)
|
||||
}
|
||||
|
||||
// Check if environment is already ready (using cache to speed up repeated checks)
|
||||
if CheckEnvironmentReady(s.envPath, "from nemo.collections.asr.models import SortformerEncLabelModel") {
|
||||
modelPath := filepath.Join(s.envPath, "diar_streaming_sortformer_4spk-v2.nemo")
|
||||
@@ -179,11 +184,6 @@ func (s *SortformerAdapter) PrepareEnvironment(ctx context.Context) error {
|
||||
return fmt.Errorf("failed to download Sortformer model: %w", err)
|
||||
}
|
||||
|
||||
// Create diarization script
|
||||
if err := s.copyDiarizationScript(); err != nil {
|
||||
return fmt.Errorf("failed to create diarization script: %w", err)
|
||||
}
|
||||
|
||||
s.initialized = true
|
||||
logger.Info("Sortformer environment prepared successfully")
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user