To use, copy the code below and save with file extension .R then install the R programming language to run.
## Code for turning lyrics screenshots to text
## Author: Cairaguas Gonzalez
## Last edited: 6/3/2023
## https://cran.r-project.org/web/packages/tesseract/vignettes/intro.html
## prepare
# install.packages("tesseract")
library(tesseract)
spanish <- tesseract("spa")
## see files in directory and copy one into fn.image manually
dir()
## pull text from image
fn.image = "ya-no-vuelvas_lupita_infante.png"
text <- tesseract::ocr(fn.image, engine = spanish)
cat(text)
str(text)
class(text)
## write text to rich text file to preserve accents
fn.text = gsub(".png", ".rtf", fn.image)
write.table(text, file = fn.text, fileEncoding="UTF-8")
## optional - open file
file.show(fn.text)