Created
March 29, 2024 10:15
-
-
Save agricolamz/1cddab5f08a7eb6a1ed92463ff7b2c70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
speech_to_text <- function(audio, | |
output_name = "output", | |
model_path = "ggml-large-v3.bin"){ | |
library(tidyverse) | |
library(audio.whisper) | |
# convert to the format specs --------------------------------------------- | |
tmp <- tempdir() | |
str_glue("ffmpeg -i {audio} -ar 16000 -ac 1 -c:a pcm_s16le {tmp}/{output_name}.wav") |> | |
system() | |
# load and run model ------------------------------------------------------ | |
model <- whisper(model_path) | |
result <- predict(model, | |
str_glue("{tmp}/{output_name}.wav"), | |
language = "ru") | |
# write down results ------------------------------------------------------ | |
result$data |> | |
as.data.frame() |> | |
write_csv(str_glue("{output_name}.csv")) | |
result$params | |
print(result$timing) | |
} | |
speech_to_text(audio = "test.wav", output_name = "test") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment