GhostNaN / whisper-subs

WhisperSubs is a mpv lua script to generate subtitles at runtime with whisper.cpp on Linux
MIT License
43 stars 2 forks source link

Feature: Allowing customization via mpv.conf #1

Closed SanmayJoshi closed 6 months ago

SanmayJoshi commented 6 months ago

Current workflow

User has to edit the line local WHISPER_CMD = "whisper.cpp -m /models/ggml/whisper-ggml-medium.bin --threads 6 --language en" in Lua script for their system.

Recommendation

User can specify in mpv.conf

whisper_location=/path/to/model
whisper_threads=6
whisper_language=en

In Lua script, we may modify the WHISPER_CMD as below:

local whisper_location = mp.get_option('whisper_location', '/path/to/model')
local whisper_threads = mp.get_option('whisper_threads', '6')
local whisper_language = mp.get_option('whisper_language', 'en')

local WHISPER_CMD = string.format("whisper.cpp -m %s --threads %s --language %s", whisper_location, whisper_threads, whisper_language)

Note

I wanted to open a PR, however, I was not really clear as to where the whisper.cpp file is to be stored, and whether that also needs to be taken from the user as input via mpv.conf

GhostNaN commented 6 months ago

I don't believe that would make setting this script up any easier. As you would have to make a mpv option for a lot of whisper.cpp args. And this script just uses the main.cpp command-line interface anyways. So I think it would just be simpler to use that as a reference. The only utility I could see using the mpv options instead would be to guardrail the args. Such as --file or --output-csv should never be used, as it would interfere with the script.

I was not really clear as to where the whisper.cpp file is to be stored

Wherever you want. For example, I keep mine in /usr/local/bin/whisper.cpp so I don't have to specify.
WHISPER_CMD is just getting sent to os.execute() like any other command.