Transcripts in the four formats that the podcast namespace allows, read into one shape and written back: SRT, WebVTT, the JSON segments format and the constrained HTML form, plus plain text.
Each format has its reader, parse-srt, parse-vtt, parse-json, parse-html and parse-text, and parse picks one by the type or by the file. The first three have writers too, emit-srt, emit-vtt and emit-json.
A transcript is a map:
{:format :vtt ; :srt :json :html :text
:segments [{:start-time 0.0 :end-time 2.76 :speaker "Sarah"
:body "…"}]}
Times are seconds, and :end-time and :speaker are there when the source had them. A WebVTT cue with inline timestamps has the :runs of its text too, each with its :start-time and :text, e.g. a word each in a word-level transcript. Speakers are read from these:
Reading is lenient and never throws on content. The report says what it had to forgive, e.g. times written as strings, an SRT wrapped in HTML or a declared type that doesn't match the file. The report is in the metadata.
Transcripts in the four formats that the podcast namespace allows, read
into one shape and written back: SRT, WebVTT, the JSON segments format
and the constrained HTML form, plus plain text.
Each format has its reader, parse-srt, parse-vtt, parse-json, parse-html
and parse-text, and parse picks one by the type or by the file. The
first three have writers too, emit-srt, emit-vtt and emit-json.
A transcript is a map:
{:format :vtt ; :srt :json :html :text
:segments [{:start-time 0.0 :end-time 2.76 :speaker "Sarah"
:body "…"}]}
Times are seconds, and :end-time and :speaker are there when the source
had them. A WebVTT cue with inline timestamps has the :runs of its text
too, each with its :start-time and :text, e.g. a word each in a
word-level transcript. Speakers are read from these:
- the voice spans of WebVTT, which name the speaker of their cue, or of
the cues that follow too in a file that marks only the changes of
speaker
- the cite elements of HTML
- the fields of JSON
- the "Name:" or "[Name]:" prefixes of caption files, which mark a
change of speaker, so the name carries over the cues that follow
Reading is lenient and never throws on content. The report says what it
had to forgive, e.g. times written as strings, an SRT wrapped in HTML or
a declared type that doesn't match the file. The report is in the
metadata.(at transcript seconds)The segment of transcript being spoken seconds into the media, among
the segments that have a start time.
The segment of `transcript` being spoken `seconds` into the media, among the segments that have a start time.
(emit-json transcript)(emit-json transcript {:keys [pretty?] :or {pretty? true} :as opts})The transcript in the JSON transcript format, indented unless opts
has :pretty? false. Segments without a start time are left out.
The `transcript` in the JSON transcript format, indented unless `opts` has :pretty? false. Segments without a start time are left out.
(emit-srt transcript)The transcript as SRT, with one numbered cue for each segment that has
a start time, and the speaker as a "Name: " prefix.
The `transcript` as SRT, with one numbered cue for each segment that has a start time, and the speaker as a "Name: " prefix.
(emit-vtt transcript)The transcript as WebVTT, with the speakers as voice spans and the
timed runs of a segment as inline timestamps. Segments without a start
time are left out.
The `transcript` as WebVTT, with the speakers as voice spans and the timed runs of a segment as inline timestamps. Segments without a start time are left out.
The transcript format of each MIME type that podcast:transcript gives.
The transcript format of each MIME type that podcast:transcript gives.
(matches transcript q)(matches transcript q {:keys [length] :or {length passage-length} :as opts})The passages of transcript that match the query q, each with :parts
that mark the matches in its :body, with the opts below.
A passage is a run of segments by one speaker of at least the :length
in opts, merged into one turn, with the :start-time of the segment
where its first match is, e.g. for a player to list where words are
said and seek there. A caption file matches by a cue or two, and a
word-level transcript by a phrase. The opts are those of
dk.simongray.drop-in-search.queries/parse, and :length, 60 characters by
default.
The passages of `transcript` that match the query `q`, each with :parts that mark the matches in its :body, with the `opts` below. A passage is a run of segments by one speaker of at least the :length in `opts`, merged into one turn, with the :start-time of the segment where its first match is, e.g. for a player to list where words are said and seek there. A caption file matches by a cue or two, and a word-level transcript by a phrase. The `opts` are those of dk.simongray.drop-in-search.queries/parse, and :length, 60 characters by default.
(parse s)(parse s type)The transcript map of s, in the format that type names: a MIME type
of podcast:transcript, or one of format-keys.
Without a type, the format is sniffed. When the file is plainly in another format than its type says, it's read as what it is, and the report names the mismatch.
A sniff for JSON or HTML can be wrong, since plain text can start with a brace or hold a p tag. When such a reading finds no segments, the file is read as its type says after all, or as plain text when it names none.
The transcript map of `s`, in the format that `type` names: a MIME type of podcast:transcript, or one of format-keys. Without a type, the format is sniffed. When the file is plainly in another format than its type says, it's read as what it is, and the report names the mismatch. A sniff for JSON or HTML can be wrong, since plain text can start with a brace or hold a p tag. When such a reading finds no segments, the file is read as its type says after all, or as plain text when it names none.
(parse-html s)The transcript map of the HTML transcript s, a sequence of cite
speakers, time starts and p paragraphs.
Some exports wrap every line of an SRT file in a p. Such a file is read as the SRT that it is, and the report says so.
The transcript map of the HTML transcript `s`, a sequence of cite speakers, time starts and p paragraphs. Some exports wrap every line of an SRT file in a p. Such a file is read as the SRT that it is, and the report says so.
(parse-json s)The transcript map of the JSON transcript s, whose segments have a
speaker, a startTime, an endTime and a body.
Bad content doesn't throw, and the report says what was forgiven:
The transcript map of the JSON transcript `s`, whose segments have a speaker, a startTime, an endTime and a body. Bad content doesn't throw, and the report says what was forgiven: - times written as strings are read as numbers - a file that isn't a JSON object reads as no segments - a segment that isn't an object is left out - a speaker that isn't text is left out, but a number counts as text
(parse-srt s)The transcript map of the SRT text s.
The transcript map of the SRT text `s`.
(parse-text s)The transcript map of the plain-text transcript s, with a segment for
each paragraph. A "Name:" prefix gives the speaker, which carries over
the paragraphs that follow.
The transcript map of the plain-text transcript `s`, with a segment for each paragraph. A "Name:" prefix gives the speaker, which carries over the paragraphs that follow.
(parse-vtt s)The transcript map of the WebVTT text s, whose cues webvtt-clj reads
as a browser does.
A voice span names the speaker of its cue alone, unless the file marks only where the speaker changes, when the speaker carries over the cues that follow, and the report says so. A "Name:" prefix always carries over. A cue whose timings don't parse is left out, and the report counts those.
The transcript map of the WebVTT text `s`, whose cues webvtt-clj reads as a browser does. A voice span names the speaker of its cue alone, unless the file marks only where the speaker changes, when the speaker carries over the cues that follow, and the report says so. A "Name:" prefix always carries over. A cue whose timings don't parse is left out, and the report counts those.
(report transcript)The diagnostics recorded while reading transcript.
The diagnostics recorded while reading `transcript`.
(sniff s)The likely format of the transcript text s. Cue timings come before
markup, and markup counts only when the text starts with it, since a
cue or a paragraph of plain text may mention a tag.
The likely format of the transcript text `s`. Cue timings come before markup, and markup counts only when the text starts with it, since a cue or a paragraph of plain text may mention a tag.
(text transcript)The plain text of transcript: the bodies of its segments, with a line
for each speaker turn and the speakers as prefixes.
The plain text of `transcript`: the bodies of its segments, with a line for each speaker turn and the speakers as prefixes.
(turns transcript)The transcript with each run of segments by the same speaker merged
into one turn, which spans their time and joins their text by spaces.
Segments without a speaker stay as they are. A word-level transcript reads as prose this way.
The `transcript` with each run of segments by the same speaker merged into one turn, which spans their time and joins their text by spaces. Segments without a speaker stay as they are. A word-level transcript reads as prose this way.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |