alphacep / vosk-api

Offline speech recognition API for Android, iOS, Raspberry Pi and servers with Python, Java, C# and Node
Apache License 2.0
7.57k stars 1.06k forks source link

How can I disable output to the console? #1355

Closed Zapzatron closed 1 year ago

Zapzatron commented 1 year ago

How can I disable output to the console? I only need the full generated text in the output without intermediate text.

nshmyrev commented 1 year ago

It depends on the code you are running.

Zapzatron commented 1 year ago
def vosk_run(file, language, model_size):
    small_model_path = "models/vosk-model-small-ru-0.22"
    big_model_path = "models/vosk-model-ru-0.42"
    if model_size == "small":
        last_path = small_model_path
    elif model_size == "big":
        last_path = big_model_path
    else:
        print("Invalid model size")
        return
    print(f"vosk_{model_size}_{language}")
    # logging NOTSET
    vosk_text = subprocess.run(["vosk-transcriber", "--model", last_path, "-i", file, "-l", language],
                               encoding="utf-8", capture_output=True, text=True)
    print(vosk_text.stdout.split("\n")[0])

There is a lot of text in this code in vosk_text.stderr, how do I disable its creation?

nshmyrev commented 1 year ago

You'd better use vosk api directly instead of vosk-transcriber.

Zapzatron commented 1 year ago

How can I use this?

nshmyrev commented 1 year ago

See example file here:

https://github.com/alphacep/vosk-api/blob/master/python/example/test_ffmpeg.py

Zapzatron commented 1 year ago

image

How can I disable these logs?

Zapzatron commented 1 year ago

vosk.SetLogLevel(-1) disabled logs