Skip to content

Conversation

@LawrenceBorst
Copy link
Member

added a flag that lets you specify an output path
represented by the 'output_set'
Public API unchanged

I needed a way to direct my AcousticsDerivator output to some folder, and this works well

I could've changed some of the steps towards the end of derive_annotations, where it imports the changes into the annotation metadata, but this turned out to be messy and tricky.

In fact, there was an easy and very elegant way to do it! We can actually run an automated importation that puts it in the format expected of ChildProject.

The only caveat now is that such an importation requires a raw folder with the file stems the same as those for the recordings, so we need to do a bit of renaming after running the derivation.

In code that looks something like this in the end

class Acoustics(ModelPlugin):
    def run_model(self, dataset_dir: Path, output_dir: Path) -> None:
        project = ChildProject(dataset_dir)
        am = AnnotationManager(project)

        acoustic_derivator = AcousticDerivator()
        am._derive_annotations("vtc", str(output_dir), acoustic_derivator, overwrite_existing=True, output_as_path=True)

        self._make_outputs_raw(output_dir)

        return
    
    def _make_outputs_raw(self, output_dir) -> None:
        """
        Here we are cheating a little bit. The idea will be that acoustics is
        "just another importation". But for this to work we have to change,
        that is, to use ChildProject's importation utilities, we have to
        1) set "converted" folder to "raw"
        2) rename filenames to remove the duration metadata

        Then Echolalia can run the importation :)
        """
        raw = output_dir / "raw"
        converted = output_dir / "converted"
        if raw.exists():
            shutil.rmtree(raw)

        for file in converted.rglob("*.csv"):
            self._rename_file(file)

        shutil.move(converted, raw)
    
    def _rename_file(self, file: Path) -> None:
        stem = file.stem
        desired_stem = '_'.join(stem.split("_")[0:-2])

        file.rename(file.with_stem(desired_stem))

@LawrenceBorst
Copy link
Member Author

Unsure about failing tests, the same tests fail on main 🤷🏽‍♂️

@LoannPeurey
Copy link
Contributor

return self._derive_annotations(self,

I think you need to remove the self argument here, given that it is a method, and the first positional argument then is the input_set

added a flag that lets you specify an output path
represented by the 'output_set'
Public API unchanged
@LoannPeurey LoannPeurey changed the base branch from master to pre-release January 13, 2026 10:07
@LoannPeurey LoannPeurey merged commit 6231059 into pre-release Jan 13, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants