as_subtitle: Convert an R object to a 'subtitles' object

Description Usage Arguments Examples

View source: R/read_subtitles.R

Description

Convert an R object to a subtitles object

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
as_subtitle(x, format = "auto", clean.tags = TRUE,
  metadata = data.frame(), frame.rate = NA, encoding = "auto", ...)

## Default S3 method:
as_subtitle(x, format = "auto", clean.tags = TRUE,
  metadata = data.frame(), frame.rate = NA, encoding = "auto", ...)

## S3 method for class 'character'
as_subtitle(x, format = "auto", clean.tags = TRUE,
  metadata = data.frame(), frame.rate = NA, encoding = "auto", ...)

Arguments

x

an R object that can be coerced into a subtitles object

format

a character string specifying the format of the subtitles. Four formats can be read: "subrip", "substation", "microdvd", "subviewer" (v.2) and "webvtt". Default is "auto" which tries to detect automatically the format of the file from its extension.

clean.tags

logical. If "TRUE" (default), formating tags are deleted from subtitles using clean_tags.

metadata

a one-row dataframe or tibble, or any object that can be coerced into a one-row tibble by link[tibble]{as_tibble}.

frame.rate

a numeric value giving the frame rate in frames per second. Only relevant for MicroDVD format. If NA (default), the function tries to extract the frame.rate from the file. If it fails, the frame rate is set at 24p (23.976).

encoding

the name of the encoding to be used. Default is "auto" and uses guess_encoding to detect encoding.

...

passed on to downstream methods.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
as_subtitle(
  c("WEBVTT",
    "X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000",
    "",
    "3",
    "00:00:21.199 --> 00:00:22.333", ">> FEMALE SPEAKER:",
    "Don't stay up too late.",
    "",
    ""
  ), format = "webvtt"
)

fkeck/subtools documentation built on Dec. 2, 2019, 3:19 a.m.