BoldTranscriptsEx.Convert.AssemblyAI (bold_transcripts_ex v0.5.1)
Handles conversion of AssemblyAI transcription files to Bold format.
This module provides functionality to:
- Convert AssemblyAI transcripts to Bold format
- Convert chapter data to WebVTT format
- Handle both v1 and v2 of the Bold format
Summary
Functions
Converts chapter data from an AssemblyAI transcript to WebVTT format.
Converts an AssemblyAI transcript to the Bold Transcript format.
Functions
Converts chapter data from an AssemblyAI transcript to WebVTT format.
Parameters
transcript
: The decoded transcript map containing chapter data.opts
: Optional parameters (unused for now, but included for future flexibility).
Returns
{:ok, webvtt_string}
- Successfully converted chapters to WebVTT format{:error, reason}
- If no chapters are found or conversion fails
Examples
iex> transcript = %{
...> "chapters" => [
...> %{
...> "start" => 1000,
...> "end" => 5000,
...> "gist" => "Introduction"
...> }
...> ]
...> }
iex> BoldTranscriptsEx.Convert.AssemblyAI.chapters_to_webvtt(transcript)
{:ok, "WEBVTT\n\n1\n00:00:01.000 --> 00:00:05.000\nIntroduction\n"}
Converts an AssemblyAI transcript to the Bold Transcript format.
Parameters
transcript
: The JSON string or decoded map of the transcript data from AssemblyAI.opts
: Options for the conversion::version
: The Bold format version to use (1 or 2). Defaults to 2.:paragraphs
: Optional paragraphs data as JSON string.
Returns
{:ok, bold_transcript}
- Successfully converted transcript where:bold_transcript
is a map containing:"metadata"
- Information about the transcript"utterances"
- List of speech segments with timing"paragraphs"
- (Optional) List of paragraph segments
{:error, reason}
- If conversion fails
Examples
# Basic conversion
iex> json = ~s({"audio_duration": 10.5, "language_code": "en"})
iex> BoldTranscriptsEx.Convert.AssemblyAI.transcript_to_bold(json)
{:ok, %{
"metadata" => %{
"duration" => 10.5,
"language" => "en",
"source_vendor" => "assemblyai"
},
"utterances" => []
}}
# With version specified
iex> BoldTranscriptsEx.Convert.AssemblyAI.transcript_to_bold(json, version: 1)
{:ok, %{...}}