mario: Run Mario to create a video

View source: R/plumber_functions.R

marioR Documentation

Run Mario to create a video

Description

Run Mario to create a video

Usage

mario(
  file,
  script = NULL,
  api_url = mario_api_url(),
  api_key = Sys.getenv("CONNECT_API_KEY"),
  voice = NULL,
  service = NULL,
  target = NULL,
  token = NULL,
  return_images = FALSE,
  ...
)

mario_translate(
  file,
  api_url = mario_api_url(),
  api_key = Sys.getenv("CONNECT_API_KEY"),
  target = NULL,
  token = NULL,
  ...
)

Arguments

file

An input file, such as a PPTX, Google Slide ID or URL, or a PDF (script needed)

script

A script of the words needed to be said over the slides.

api_url

URL for the Plumber API

api_key

API key for RStudio Cnnect

voice

The voice used to synthesize the audio

service

Service to use or list voices

target

The language code (2-character) to translate to.

token

A Token object for Google Slides for your account. Usually created from googledrive::drive_token

return_images

Should images be base64-encoded if slides are converted to PNG files?

...

additional options to send to GET

Value

A response with the response from the API

Examples

## Not run: 
if (mario_have_api_key()) {
  # Google Slide ID
  id = "1Opt6lv7rRi7Kzb9bI0u3SWX1pSz1k7botaphTuFYgNs"
  res = mario(id)
  httr::stop_for_status(res)
  if (requireNamespace("ariExtra", quietly = TRUE)) {
    # Using PDF
    pdf_file = system.file("extdata", "example.pdf", package = "ariExtra")
    script = tempfile(fileext = ".txt")
    paragraphs = c("hey", "ho")
    writeLines(paragraphs, script)

    # Trying with script or paragraphs
    res = mario(pdf_file, script, return_images = TRUE)
    httr::stop_for_status(res)
    out = mario_content(res)
    res = mario(pdf_file, paragraphs)
    httr::stop_for_status(res)


    # Using PPTX
    file = system.file("extdata", "example.pptx", package = "ariExtra")
    res = mario(file)
    # Set of PNGs
    file = system.file("extdata", c("example_1.png", "example_2.png"),
                       package = "ariExtra")

    res = mario(file, script)
    httr::stop_for_status(res)
    res = mario(file, paragraphs)
    httr::stop_for_status(res)




    id = paste0("https://docs.google.com/presentation/d/",
                "1Tg-GTGnUPduOtZKYuMoelqUNZnUp3vvg_7TtpUPL7e8",
                "/edit#slide=id.g154aa4fae2_0_58")
    id = ariExtra::get_slide_id(id)
    words = strsplit(
      c("hey what do you think of this thing? ",
        "I don't know what to type here."), split = " ")
    script = tempfile(fileext = ".txt")
    script = writeLines(
      rep(unlist(words),
          length.out = 41), con = script)

    if (requireNamespace("googledrive", quietly = TRUE)) {
      token = googledrive::drive_token()
      out = mario(file = id,
                  script = script,
                  token = token,
                  target = "es")
    }
  }
}

## End(Not run)

jhudsl/mario documentation built on Aug. 27, 2023, 2:43 a.m.