Skip to content

Normalize the origin of segmented audio file results - #209

Open
antonsoo wants to merge 1 commit into
audeering:mainfrom
antonsoo:fix/segment-file-start-types
Open

antonsoo wants to merge 1 commit into
audeering:mainfrom
antonsoo:fix/segment-file-start-types

Conversation

@antonsoo

Copy link
Copy Markdown

Segment.process_file() accepts numeric and string start positions through its underlying Process, then adds the original argument to the returned timedelta values. Calls such as start=0.25 or start="250ms" therefore raise after the audio has been processed.

Use the normalized start time from the Process result when offsetting the segments. This also handles sample-count strings without repeating their conversion and preserves precise Timedelta origins.

Add regression cases for integer/float seconds, unit strings, sample-count strings, missing starts and nanosecond precision.

Validation:

  • Full pytest: 678 passed, 54 xfailed, 100% coverage.
  • All configured pre-commit checks pass.
  • 88 recorded-speech configurations check segmentation timestamps and downstream mean-square features against independent sample-based references. All 24 formerly failing calls complete, and all 64 working control records remain identical.

Use the start time from the underlying Process result when offsetting returned segments. This accepts documented numeric and string starts without redoing their conversion, and keeps the existing precise Timedelta origin.
@sourcery-ai

sourcery-ai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Normalize segment origins through the underlying Process result before combining them with relative segment timestamps, fixing numeric and string starts while preserving precision; add broad regression coverage for supported start types.

Sequence diagram for normalized segmented audio origins

sequenceDiagram
    participant Caller
    participant Segment
    participant Process
    participant Pandas
    participant AudioFormat

    Caller->>Segment: process_file(file, start, end)
    Segment->>Process: process_file(file, start, end, root, process_func_args)
    Process-->>Segment: y with normalized start index
    Segment->>Pandas: y.values[0]
    Segment->>Pandas: y.index.get_level_values(start)[0]
    Segment->>AudioFormat: segmented_index(files, starts=index starts + normalized start)
    AudioFormat-->>Caller: segmented audio results
Loading

File-Level Changes

Change Details Files
Offset segmented results using the normalized origin returned by the underlying process.
  • Retain the complete process result before extracting segment offsets.
  • Read the normalized start level from the returned index and add it to relative segment timestamps.
  • Avoid re-converting sample-count strings and preserve nanosecond-precision timedeltas.
audinterface/core/segment.py
Add regression coverage for all supported segment start representations.
  • Verify missing, numeric, unit-string, sample-count-string, and Timedelta starts normalize to the expected timestamps.
  • Cover integer and floating-point seconds plus nanosecond precision.
tests/test_segment.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

This branch has not been deployed

No deployments
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.

1 participant