Use some of the CLI arguments inside my python code #1951
-
Hi all I am sorry if this is a stupid question. I cannot seem to find any documentation on how to do this, or understand from the source code how to implement what I want to achieve. I want to, amongst other things, limit the number of threads whisper is allowed to use, as it will be running on a server that shares resources with other applications. So there are a couple of things that is available on the CLI, but does not seem to be available to the
I would like to change it so that:
Any possible examples I can look at to achieve what I want to achieve? TIA for anyone willing to help. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
You can pass those arguments like this: import whisper
from whisper.utils import get_writer
audio_path = "audio.mp3"
model_dir = "path/to/dir"
output_dir = "path/to/dir"
torch.set_num_threads(2)
model = whisper.load_module("large", download_root=model_dir)
result = model.transcribe(audio_path, word_timestamps=True)
srt_writer = get_writer("srt", output_dir)
vtt_writer = get_writer("vtt", output_dir)
srt_writer(result, audio_path)
vtt_writer(result, audio_path) |
Beta Was this translation helpful? Give feedback.
-
see how whisper pass CLI args: https://github.com/openai/whisper/blob/main/whisper/transcribe.py#L511 |
Beta Was this translation helpful? Give feedback.
You can pass those arguments like this: