Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing alignments #914

Merged
merged 4 commits into from
Dec 13, 2022
Merged

fixing alignments #914

merged 4 commits into from
Dec 13, 2022

Conversation

lubacien
Copy link
Contributor

@lubacien lubacien commented Dec 8, 2022

Hello,

This was not working as it created a list of segments which was appended instead of appending each segment separately. Now it seems to work.

thanks

@@ -671,7 +671,8 @@ def with_alignment_from_ctm(
num_overspanned += len(alignment)
segments.append(fastcopy(seg, alignment={type: alignment}))
else:
segments.append([s for s in self.find(recording_id=reco_id)])
for s in self.find(recording_id=reco_id):
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can also use extend() here.

Suggested change
for s in self.find(recording_id=reco_id):
segments.extend([s for s in self.find(recording_id=reco_id)])

Copy link
Collaborator

Choose a reason for hiding this comment

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

It should be possible to do even segments.extend(self.find(recording_id=reco_id)).

Can we add a unit test to cover this case?

@pzelasko
Copy link
Collaborator

pzelasko commented Dec 9, 2022

Thanks for your first contribution! Can you also help us with testing the code?

@lubacien
Copy link
Contributor Author

ok, I will work on it

@lubacien
Copy link
Contributor Author

lubacien commented Dec 12, 2022

I found another error, which happens when we try to write the ctm:
if type in s.alignment: TypeError: argument of type 'NoneType' is not iterable

When there is no recording_id found, we do not write any alignment, but when there is a recording id without an alignment we write {type: []}.
Now this is also solved, by adding an empty alignment also if we do not find the recording_id. So the line becomes:
segments.extend([fastcopy(s, alignment={type: []}) for s in self.find(recording_id=reco_id)])

@desh2608 desh2608 added this to the v1.12 milestone Dec 13, 2022
@desh2608 desh2608 merged commit 49cea86 into lhotse-speech:master Dec 13, 2022
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