removed --wav-only from calls clip cmd
Dependencies
- [2]
2P27XV3Dfixed cyclo over 30 - [3]
KLUEQ6X5cyclo 21+ - [4]
KZKLAINJrun out of space on nest, cleaned out - [5]
GVOVKH5Rmore cyclo refactoring
Change contents
- edit in tools/calls_clip_bench_test.go at line 302
}}func BenchmarkFullPipelineWavOnly(b *testing.B) {samples, sr, _ := utils.ReadWAVSamples(benchWAV)b.ResetTimer()b.ReportAllocs()for i := 0; i < b.N; i++ {segSamples := utils.ExtractSegmentSamples(samples, sr, 872, 895)outputSR := srif sr > 16000 {segSamples = utils.ResampleRate(segSamples, sr, 16000)outputSR = 16000}f, _ := os.CreateTemp("", "bench_*.wav")utils.WriteWAVFile(f.Name(), segSamples, outputSR)f.Close()os.Remove(f.Name()) - replacement in tools/calls_clip.go at line 18
File string `json:"file"`Folder string `json:"folder"`Output string `json:"output"`Prefix string `json:"prefix"`Filter string `json:"filter"`Species string `json:"species"`Certainty int `json:"certainty"`Size int `json:"size"`Color bool `json:"color"`WavOnly bool `json:"wav_only"`Night bool `json:"night"`Day bool `json:"day"`Lat float64 `json:"lat"`Lng float64 `json:"lng"`Timezone string `json:"timezone"`File string `json:"file"`Folder string `json:"folder"`Output string `json:"output"`Prefix string `json:"prefix"`Filter string `json:"filter"`Species string `json:"species"`Certainty int `json:"certainty"`Size int `json:"size"`Color bool `json:"color"`Night bool `json:"night"`Day bool `json:"day"`Lat float64 `json:"lat"`Lng float64 `json:"lng"`Timezone string `json:"timezone"` - replacement in tools/calls_clip.go at line 119
clips, skipped, errs := processFile(dataPath, input.Output, input.Prefix, input.Filter, speciesName, callType, input.Certainty, imgSize, input.Color, input.WavOnly, input.Night, input.Day, input.Lat, input.Lng, input.Timezone)clips, skipped, errs := processFile(dataPath, input.Output, input.Prefix, input.Filter, speciesName, callType, input.Certainty, imgSize, input.Color, input.Night, input.Day, input.Lat, input.Lng, input.Timezone) - replacement in tools/calls_clip.go at line 140
clips, skipped, errs := processFile(dataPath, input.Output, input.Prefix, input.Filter, speciesName, callType, input.Certainty, imgSize, input.Color, input.WavOnly, input.Night, input.Day, input.Lat, input.Lng, input.Timezone)clips, skipped, errs := processFile(dataPath, input.Output, input.Prefix, input.Filter, speciesName, callType, input.Certainty, imgSize, input.Color, input.Night, input.Day, input.Lat, input.Lng, input.Timezone) - replacement in tools/calls_clip.go at line 177
func processFile(dataPath, outputDir, prefix, filter, speciesName, callType string, certainty, imgSize int, color, wavOnly, night, day bool, lat, lng float64, timezone string) ([]string, int, []string) {func processFile(dataPath, outputDir, prefix, filter, speciesName, callType string, certainty, imgSize int, color, night, day bool, lat, lng float64, timezone string) ([]string, int, []string) { - replacement in tools/calls_clip.go at line 218
clips, errors = processSegments(matchingSegments, dataPath, samples, sampleRate, outputDir, prefix, basename, imgSize, color, wavOnly)clips, errors = processSegments(matchingSegments, dataPath, samples, sampleRate, outputDir, prefix, basename, imgSize, color) - replacement in tools/calls_clip.go at line 258
func processSegments(segments []*utils.Segment, dataPath string, samples []float64, sampleRate int, outputDir, prefix, basename string, imgSize int, color, wavOnly bool) ([]string, []string) {func processSegments(segments []*utils.Segment, dataPath string, samples []float64, sampleRate int, outputDir, prefix, basename string, imgSize int, color bool) ([]string, []string) { - replacement in tools/calls_clip.go at line 264
clipFiles, err := generateClip(samples, sampleRate, outputDir, prefix, basename, seg.StartTime, seg.EndTime, imgSize, color, wavOnly)clipFiles, err := generateClip(samples, sampleRate, outputDir, prefix, basename, seg.StartTime, seg.EndTime, imgSize, color) - replacement in tools/calls_clip.go at line 272
clips, errors = processSegmentsParallel(segments, dataPath, samples, sampleRate, outputDir, prefix, basename, imgSize, color, wavOnly)clips, errors = processSegmentsParallel(segments, dataPath, samples, sampleRate, outputDir, prefix, basename, imgSize, color) - replacement in tools/calls_clip.go at line 279
func processSegmentsParallel(segments []*utils.Segment, dataPath string, samples []float64, sampleRate int, outputDir, prefix, basename string, imgSize int, color, wavOnly bool) ([]string, []string) {func processSegmentsParallel(segments []*utils.Segment, dataPath string, samples []float64, sampleRate int, outputDir, prefix, basename string, imgSize int, color bool) ([]string, []string) { - replacement in tools/calls_clip.go at line 293
clipFiles, err := generateClip(samples, sampleRate, outputDir, prefix, basename, seg.StartTime, seg.EndTime, imgSize, color, wavOnly)clipFiles, err := generateClip(samples, sampleRate, outputDir, prefix, basename, seg.StartTime, seg.EndTime, imgSize, color) - replacement in tools/calls_clip.go at line 326
func generateClip(samples []float64, sampleRate int, outputDir, prefix, basename string, startTime, endTime float64, imgSize int, color, wavOnly bool) ([]string, error) {func generateClip(samples []float64, sampleRate int, outputDir, prefix, basename string, startTime, endTime float64, imgSize int, color bool) ([]string, error) { - replacement in tools/calls_clip.go at line 350
// Generate spectrogram and PNG unless --wav-onlyif !wavOnly {pngPath := filepath.Join(outputDir, baseName+".png")pngPath := filepath.Join(outputDir, baseName+".png") - replacement in tools/calls_clip.go at line 352
spectSampleRate := outputSampleRateconfig := utils.DefaultSpectrogramConfig(spectSampleRate)spectrogram := utils.GenerateSpectrogram(segSamples, config)if spectrogram == nil {return nil, fmt.Errorf("failed to generate spectrogram")}spectSampleRate := outputSampleRateconfig := utils.DefaultSpectrogramConfig(spectSampleRate)spectrogram := utils.GenerateSpectrogram(segSamples, config)if spectrogram == nil {return nil, fmt.Errorf("failed to generate spectrogram")} - replacement in tools/calls_clip.go at line 359
// Create image (grayscale or color)var img image.Imageif color {colorData := utils.ApplyL4Colormap(spectrogram)img = utils.CreateRGBImage(colorData)} else {img = utils.CreateGrayscaleImage(spectrogram)}if img == nil {return nil, fmt.Errorf("failed to create image")}// Create image (grayscale or color)var img image.Imageif color {colorData := utils.ApplyL4Colormap(spectrogram)img = utils.CreateRGBImage(colorData)} else {img = utils.CreateGrayscaleImage(spectrogram)}if img == nil {return nil, fmt.Errorf("failed to create image")} - replacement in tools/calls_clip.go at line 371
resized := utils.ResizeImage(img, imgSize, imgSize)resized := utils.ResizeImage(img, imgSize, imgSize) - replacement in tools/calls_clip.go at line 373
// Write PNG (O_EXCL fails atomically if file exists)pngFile, err := os.OpenFile(pngPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0644)if err != nil {if os.IsExist(err) {return nil, fmt.Errorf("file already exists: %s", pngPath)}return nil, fmt.Errorf("failed to create PNG: %w", err)// Write PNG (O_EXCL fails atomically if file exists)pngFile, err := os.OpenFile(pngPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0644)if err != nil {if os.IsExist(err) {return nil, fmt.Errorf("file already exists: %s", pngPath) - replacement in tools/calls_clip.go at line 379
if err := utils.WritePNG(resized, pngFile); err != nil {_ = pngFile.Close()return nil, fmt.Errorf("failed to write PNG: %w", err)}if err := pngFile.Close(); err != nil {return nil, fmt.Errorf("failed to close PNG: %w", err)}files = append(files, pngPath)return nil, fmt.Errorf("failed to create PNG: %w", err)}if err := utils.WritePNG(resized, pngFile); err != nil {_ = pngFile.Close()return nil, fmt.Errorf("failed to write PNG: %w", err)}if err := pngFile.Close(); err != nil {return nil, fmt.Errorf("failed to close PNG: %w", err) - edit in tools/calls_clip.go at line 388
files = append(files, pngPath) - edit in cmd/calls_clip.go at line 74
fmt.Fprintf(os.Stderr, " --wav-only Generate only WAV clips, skip spectrogram PNG generation\n") - edit in cmd/calls_clip.go at line 108
wavOnly bool - edit in cmd/calls_clip.go at line 146[2.27854]→[4.16374:16383](∅→∅),[4.1139138]→[4.16374:16383](∅→∅),[4.16383]→[4.1139146:1139167](∅→∅),[4.1139146]→[4.1139146:1139167](∅→∅),[4.1139167]→[2.27855:27875](∅→∅)
p.i++case "--wav-only":f.wavOnly = true - edit in cmd/calls_clip.go at line 232
WavOnly: f.wavOnly,