BoldTranscriptsEx.Utils.Chapters (bold_transcripts_ex v0.6.0)
Provides utility functions for working with chapter data.
This module handles:
- Converting between different chapter formats
- Parsing WebVTT chapter files
- Converting chapters to WebVTT format
- Time format conversions (WebVTT, milliseconds, human-readable)
Chapter data can be represented in different formats:
- WebVTT format (text with timestamps and titles)
- Bold format (list of maps with start/end times and titles)
- AssemblyAI format (embedded in transcript with gist as title)
Summary
Functions
Converts a list of chapters into WebVTT format.
Converts milliseconds to WebVTT timestamp format (HH:MM:SS.mmm)
Parses WebVTT content to extract chapters, converting them into a structured list.
Functions
Converts a list of chapters into WebVTT format.
Parameters
chapters
: A list of maps, each containing::start
- Start time as "MM:SS" or "HH:MM:SS":end
- End time in same format as start:title
- Chapter title
Returns
A string in WebVTT format with chapter markers.
Examples
iex> chapters = [
...> %{start: "0:03", end: "0:16", title: "Introduction"},
...> %{start: "0:16", end: "1:00", title: "Main Content"}
...> ]
iex> BoldTranscriptsEx.Utils.Chapters.chapters_to_webvtt(chapters)
"""
WEBVTT
1
00:00:03.000 --> 00:00:16.000
Introduction
2
00:00:16.000 --> 00:01:00.000
Main Content
"""
Converts milliseconds to WebVTT timestamp format (HH:MM:SS.mmm)
Examples
iex> ms_to_webvtt(114160)
"00:01:54.160"
iex> ms_to_webvtt(5000)
"00:00:05.000"
Parses WebVTT content to extract chapters, converting them into a structured list.
Parameters
webvtt
: The WebVTT content as a string in format:WEBVTT 1 00:00:03.000 --> 00:00:16.000 Chapter Title
Returns
A list of maps, each containing:
:start
- Start time in format "MM:SS" or "HH:MM:SS":end
- End time in same format as start:title
- Chapter title as string
Examples
iex> webvtt = """
...> WEBVTT
...>
...> 1
...> 00:00:03.000 --> 00:00:16.000
...> Introduction
...> """
iex> BoldTranscriptsEx.Utils.Chapters.parse_chapters(webvtt)
[%{start: "0:03", end: "0:16", title: "Introduction"}]