stlukey/whispercpp.py

Set params?

chrisspen opened this issue · 2 comments

How do you access and set the various parameters passed to Whisper? I see the params structure in the Whisper class, but it appears to be private and not externally accessible.

>>> from whispercpp import Whisper
>>> w = Whisper('large')
>>> w.params.processors = 4
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'whispercpp.Whisper' object has no attribute 'params'

+1. only support en output, if we can set the language to params?

I was having similar trouble as you guys so I looked for a slightly different way. This is the file I am using now:

my stt_wav.py file:

import subprocess
import sys

# Command and its arguments
command = "./whisper.cpp/main"
model = "-m ./whisper.cpp/models/ggml-base.en.bin"
file_path = "-f " + sys.argv[1]  # Get the first parameter as the wav file path

# Combine into a single command
full_command = f"{command} {model} {file_path}"

# Execute the command and capture the output
process = subprocess.Popen(full_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = process.communicate()

if not bool(error.decode('utf-8').strip()): 
    # The output variable contains the command's standard output
    decoded_str = output.decode('utf-8').strip()
    processed_str = decoded_str.replace('[BLANK_AUDIO]', '').strip()
    print("Output:", processed_str)    
else: 
    # The error variable contains the command's standard error
    print("Error:", error.decode('utf-8'))

and I execute it like this:

python stt_wav.py "./audio/wake_word_detected16k.wav"

this way I could run the standard main as you do on the command line and pass it whatever command line options I need. I also commented out a bunch of of the WHISPER_LOG_INFO() out in the whisper.cpp file and some fprintf() in the main.cpp to eliminate all the logging noise.