Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set params? #26

Open
chrisspen opened this issue Nov 5, 2023 · 2 comments
Open

Set params? #26

chrisspen opened this issue Nov 5, 2023 · 2 comments

Comments

@chrisspen
Copy link

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'
@foobarhe
Copy link

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

@contractorwolf
Copy link

contractorwolf commented Jan 8, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants