Skip to content

Commit

Permalink
adding post processing
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-roethig-db committed May 25, 2024
1 parent 2dc854c commit 40caa99
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
23 changes: 23 additions & 0 deletions amondin/post_processing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pandas as pd


def merge_rows_consecutive_speaker(transcript: pd.DataFrame) -> pd.DataFrame:
transcript['speaker_group'] = (transcript['speaker'] != transcript['speaker'].shift()).cumsum()

print(transcript.to_markdown())

transcript = transcript.groupby(['speaker_group', 'speaker']).agg({
'time_stamp': lambda x: ' '.join(x),
'text': lambda x: ' '.join(x)
}).reset_index()

transcript = transcript.drop(columns='speaker_group')

print(transcript.to_markdown())

return transcript


if __name__ == "__main__":
test_transcript = pd.read_excel("../data/test_transcript.xlsx")
merge_rows_consecutive_speaker(transcript=test_transcript)
4 changes: 3 additions & 1 deletion amondin/segment_speakers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ def segment_speakers(
# craft dict representing passage
segment = {
"speaker": list(speaker)[0],
"time_stamp": str(segment),
"start": segment.start,
"end": segment.end,
"audio": {
"raw": waveform,
"sampling_rate": sample_rate,
},
}
print(segment)

speaker_segments.append(segment)

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"numpy",
"torch",
"torchaudio",
"openpyxl",
]
)

0 comments on commit 40caa99

Please sign in to comment.