synesthR turns literary text into a single prosody score and
renders that one score as both an image and a synchronized piece of
audio. The pipeline is
read -> score -> paint / play / palette, and it is
deterministic: the same text and seed always produce the same
result.
Read and score
text <- syn_read_text(syn_example_text("en"), lang = "en")
score <- syn_score(text)
score
#> <prosody_score> — 6 sentences, lang "en"
summary(score)
#> # A tibble: 1 × 9
#> n_sentences lang mean_valence valence_range arc_start arc_end mean_length
#> <int> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 6 en -0.167 3 -0.5 0.5 14
#> # ℹ 2 more variables: mean_lex_div <dbl>, mean_punct_density <dbl>The score holds per-sentence features (valence, length, lexical
diversity, punctuation density) and a smoothed emotional
arc.
Play
out <- tempfile(fileext = ".wav")
syn_write_wav(score, out) # returns the score invisibly, pipe-friendly
file.exists(out)
#> [1] TRUE
wave <- syn_play(score)
wave
#>
#> Wave Object
#> Number of Samples: 253831
#> Duration (seconds): 5.76
#> Samplingrate (Hertz): 44100
#> Channels (Mono/Stereo): Mono
#> PCM (integer format): TRUE
#> Bit (8/16/24/32/64): 16Palette and theme
The same score yields a colour palette and a matching
ggplot2 theme:
pal <- syn_palette(score)
pal
#> <syn_palette> - 5 colours, cool, from prosody_score
#> "#294D00" background
#> "#207900" shadow
#> "#00A65D" mid
#> "#00D5A4" accent
#> "#3BFFEB" highlightBecause the image, the audio, and the palette all come from one score, they are three views of the same analysis.
