import re # table css = """ .scrollable-table { max-height: 300px; overflow-y: auto; border: 1px solid #ccc; padding: 10px; } .scrollable-table table { width: 100%; border-collapse: collapse; background-color: #FFFFFF; } .scrollable-table th, .scrollable-table td { border: 1px solid #ddd; padding: 8px; text-align: left; color: #000000 } .scrollable-table th { background-color: #EAF2FF; color: #3366CC; } """ def parse_transcript(transcript): # Regex to match the timestamps and the text pattern = re.compile(r'(\d{2}:\d{2})\s+(.+?)(?=\d{2}:\d{2}|$)', re.DOTALL) matches = pattern.findall(transcript) timestamps = [] texts = [] for match in matches: timestamps.append(match[0]) texts.append(match[1].strip()) return timestamps, texts def create_transcript_table(timestamps, transcript_text): table_html = '
Timestamp | \n' table_html += 'Transcript | \n' table_html += '
---|---|
{ts} | \n' table_html += f'{text} | \n' table_html += '