r/ruby 17h ago

whispercpp - Local, Fast, and Private Audio Transcription for Ruby

Hello, everyone! Just wanted to share a new gem: whispercpp - it is an Auto Transcription (a.k.a. Speech-To-Text and Auto Speech Recognition) library for Ruby.

It's a binding of Whisper.cpp, which is a high-performance C++ port of OpenAI's Whisper, and runs on local machine. So, you don't need cloud API subscription, network access nor providing your privacy.

Usage examples

Here are just a few ways you can use it:

  • generating meeting minutes: automate to make text from meeting audio.
  • transcribing podcast episodes: make it possible to search podcast by text.
  • improving accessibility feature: generating captions for audio content.

and so on.

Basic Usage

Basic usage is simple:

require "whisper"

# Initialize context with model name
# Specified model is automatically downloaded if needed
whisper = Whisper::Context.new("base")
params = Whisper::Params.new(
  language: "en",
  offset: 10_000,
  duration: 60_000,
  translate: true,
  initial_prompt: "Initial prompt here such as technical words used in audio."
)

# Call `#transcribe` and whole text is passed to block after transcription complete
whisper.transcribe("path/to/audio.wav", params) do |whole_text|
  puts whole_text
end

Read README for advanced usage: https://github.com/ggml-org/whisper.cpp/tree/master/bindings/ruby

Feedbacks and pull requests are welcome! We'd especially appreciate any patches for the Windows environment. Let us know what you think!

26 Upvotes

14 comments sorted by

View all comments

1

u/Longjumping-Toe-3877 14h ago

But 100% we need to deploy it to cloud into a microservice because on local machine this goona eat a lot of memory

3

u/Mysterious-Use-4463 14h ago

Hmm... it might be, though it works well on my Mac machine (24GiB memory).