INNER CODE UNIT · Python
split_text
DrewThomasson/VoxNovel · 2GPU_Audio_generation.py:58
def split_text(text, split_string, original_row):
# Split the text at the specified string and find the index of the split
split_index = text.find(split_string)
parts = text.split(split_string)
new_rows = []
start_location = original_row['Start Location']
for index, part in enumerate(parts):
new_row = original_row.copy()
if index == 0:
new_row['Text'] = part
new_row['End Location'] = start_location + split_index
else:
new_row['Text'] = split_string + part
new_row['Start Location'] = start_location + split_index
new_row['End Location'] = start_location + split_index + len(split_string) + len(part)
split_index += len(split_string) + len(part) # Update for the next part