Skip to content

Commit ab912a6

Browse files
paulirishrishikanthc
authored andcommitted
always copy scripts
1 parent 7471a2a commit ab912a6

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

internal/transcription/adapters/canary_adapter.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ func (c *CanaryAdapter) GetSupportedModels() []string {
168168
func (c *CanaryAdapter) PrepareEnvironment(ctx context.Context) error {
169169
logger.Info("Preparing NVIDIA Canary environment", "env_path", c.envPath)
170170

171+
// Copy transcription script
172+
if err := c.copyTranscriptionScript(); err != nil {
173+
return fmt.Errorf("failed to copy transcription script: %w", err)
174+
}
175+
171176
// Check if environment is already ready (using cache to speed up repeated checks)
172177
if CheckEnvironmentReady(c.envPath, "import nemo.collections.asr") {
173178
modelPath := filepath.Join(c.envPath, "canary-1b-v2.nemo")
@@ -188,11 +193,6 @@ func (c *CanaryAdapter) PrepareEnvironment(ctx context.Context) error {
188193
return fmt.Errorf("failed to download Canary model: %w", err)
189194
}
190195

191-
// Create transcription script
192-
if err := c.copyTranscriptionScript(); err != nil {
193-
return fmt.Errorf("failed to create transcription script: %w", err)
194-
}
195-
196196
c.initialized = true
197197
logger.Info("Canary environment prepared successfully")
198198
return nil

internal/transcription/adapters/parakeet_adapter.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ func (p *ParakeetAdapter) GetSupportedModels() []string {
125125
func (p *ParakeetAdapter) PrepareEnvironment(ctx context.Context) error {
126126
logger.Info("Preparing NVIDIA Parakeet environment", "env_path", p.envPath)
127127

128+
// Copy transcription scripts (standard and buffered)
129+
if err := p.copyTranscriptionScript(); err != nil {
130+
return fmt.Errorf("failed to copy transcription script: %w", err)
131+
}
132+
133+
if err := p.copyBufferedScript(); err != nil {
134+
return fmt.Errorf("failed to create buffered script: %w", err)
135+
}
136+
128137
// Check if environment is already ready (using cache to speed up repeated checks)
129138
if CheckEnvironmentReady(p.envPath, "import nemo.collections.asr") {
130139
modelPath := filepath.Join(p.envPath, "parakeet-tdt-0.6b-v3.nemo")
@@ -159,15 +168,6 @@ func (p *ParakeetAdapter) PrepareEnvironment(ctx context.Context) error {
159168
return fmt.Errorf("failed to download Parakeet model: %w", err)
160169
}
161170

162-
// Create transcription scripts (standard and buffered)
163-
if err := p.copyTranscriptionScript(); err != nil {
164-
return fmt.Errorf("failed to create transcription script: %w", err)
165-
}
166-
167-
if err := p.createBufferedScript(); err != nil {
168-
return fmt.Errorf("failed to create buffered script: %w", err)
169-
}
170-
171171
p.initialized = true
172172
logger.Info("Parakeet environment prepared successfully")
173173
return nil
@@ -557,8 +557,8 @@ func (p *ParakeetAdapter) parseResult(tempDir string, input interfaces.AudioInpu
557557
return result, nil
558558
}
559559

560-
// createBufferedScript creates the Python script for NeMo buffered inference
561-
func (p *ParakeetAdapter) createBufferedScript() error {
560+
// copyBufferedScript creates the Python script for NeMo buffered inference
561+
func (p *ParakeetAdapter) copyBufferedScript() error {
562562
scriptContent, err := nvidiaScripts.ReadFile("py/nvidia/parakeet_transcribe_buffered.py")
563563
if err != nil {
564564
return fmt.Errorf("failed to read embedded transcribe_buffered.py: %w", err)

internal/transcription/adapters/pyannote_adapter.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ func (p *PyAnnoteAdapter) GetMinSpeakers() int {
182182
func (p *PyAnnoteAdapter) PrepareEnvironment(ctx context.Context) error {
183183
logger.Info("Preparing PyAnnote environment", "env_path", p.envPath)
184184

185+
// Always ensure diarization script exists
186+
if err := p.copyDiarizationScript(); err != nil {
187+
return fmt.Errorf("failed to create diarization script: %w", err)
188+
}
189+
185190
// Check if PyAnnote is already available (using cache to speed up repeated checks)
186191
if CheckEnvironmentReady(p.envPath, "from pyannote.audio import Pipeline") {
187192
logger.Info("PyAnnote already available in environment")
@@ -198,11 +203,6 @@ func (p *PyAnnoteAdapter) PrepareEnvironment(ctx context.Context) error {
198203
return fmt.Errorf("failed to setup PyAnnote environment: %w", err)
199204
}
200205

201-
// Always ensure diarization script exists
202-
if err := p.copyDiarizationScript(); err != nil {
203-
return fmt.Errorf("failed to create diarization script: %w", err)
204-
}
205-
206206
// Verify PyAnnote is now available
207207
testCmd := exec.Command("uv", "run", "--native-tls", "--project", p.envPath, "python", "-c", "from pyannote.audio import Pipeline")
208208
if testCmd.Run() != nil {

internal/transcription/adapters/sortformer_adapter.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ func (s *SortformerAdapter) GetMinSpeakers() int {
152152
func (s *SortformerAdapter) PrepareEnvironment(ctx context.Context) error {
153153
logger.Info("Preparing NVIDIA Sortformer environment", "env_path", s.envPath)
154154

155+
// Copy diarization script
156+
if err := s.copyDiarizationScript(); err != nil {
157+
return fmt.Errorf("failed to copy diarization script: %w", err)
158+
}
159+
155160
// Check if environment is already ready (using cache to speed up repeated checks)
156161
if CheckEnvironmentReady(s.envPath, "from nemo.collections.asr.models import SortformerEncLabelModel") {
157162
modelPath := filepath.Join(s.envPath, "diar_streaming_sortformer_4spk-v2.nemo")
@@ -179,11 +184,6 @@ func (s *SortformerAdapter) PrepareEnvironment(ctx context.Context) error {
179184
return fmt.Errorf("failed to download Sortformer model: %w", err)
180185
}
181186

182-
// Create diarization script
183-
if err := s.copyDiarizationScript(); err != nil {
184-
return fmt.Errorf("failed to create diarization script: %w", err)
185-
}
186-
187187
s.initialized = true
188188
logger.Info("Sortformer environment prepared successfully")
189189
return nil

0 commit comments

Comments
 (0)