forked from muschellij2/ari_paper
-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
100 lines (82 loc) · 2.61 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
output:
github_document: default
html_document: default
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
eval = FALSE
)
```
# ari_paper
<!-- badges: start -->
<!-- badges: end -->
The goal of ari_paper is to showcase the [`ari` package](https://cran.r-project.org/package=ari). We show how to use each function and the output videos. This README uses the [`video`](https://github.com/muschellij2/video) package to render videos inside the markdown. The paper can be viewed at https://johnmuschelli.com/ari_paper/.
```{r, eval = TRUE, echo = FALSE}
library(video)
```
## Making videos with `ari`: `ari_stitch`
```{r stitch, message = FALSE}
library(tuneR)
library(ari)
result = ari_stitch(
ari_example(c("mab1.png", "mab2.png")),
list(noise(), noise()),
output = "noise.mp4")
isTRUE(result)
attributes(result)$outfile
```
```{r, eval = TRUE, echo = FALSE}
video::video("noise.mp4", elementId = "noise-video")
```
## Creating Speech from Text: `ari_spin`
Let us take a part of Mercutio's speech from Shakespeare's Romeo and Juliet [@shakespeare2003romeo] and overlay it on 2 images from the Wikipedia page about Mercutio (https://en.wikipedia.org/wiki/Mercutio):
```{r romeo}
res = ffmpeg_audio_codecs()
fdk_enabled = grepl("fdk", res[ res$codec == "aac", "codec_name"])
if (fdk_enabled) {
audio_codec = "libfdk_aac"
} else {
audio_codec = "aac"
}
speech = c(
"I will now perform part of Mercutio's speech from Shakespeare's Romeo and Juliet.",
"O, then, I see Queen Mab hath been with you.
She is the fairies' midwife, and she comes
In shape no bigger than an agate-stone
On the fore-finger of an alderman,
Drawn with a team of little atomies
Athwart men's noses as they lies asleep;")
mercutio_file = "death_of_mercutio.png"
mercutio_file2 = "mercutio_actor.png"
output = "romeo.mp4"
if (!file.exists(output)) {
run_voice = "Joanna"
ari_spin(
c(mercutio_file, mercutio_file2),
speech, output = output, voice = run_voice,
service = "amazon",
audio_codec = audio_codec)
}
```
```{r, eval = TRUE, echo = FALSE}
video::video("romeo.mp4")
```
We can also generate the video using the voice `Brian`, which is an British English male voice:
```{r romeo_gb, echo = FALSE, eval = TRUE}
output = "romeo_gb.mp4"
if (!file.exists(output)) {
run_voice = "Brian"
ari_spin(
c(mercutio_file, mercutio_file2),
speech, output = output, voice = run_voice,
service = "amazon",
audio_codec = audio_codec)
}
```
```{r, eval = TRUE, echo = FALSE}
video::video("romeo_gb.mp4")
```