talkey icon indicating copy to clipboard operation
talkey copied to clipboard

Is there a way to disable console text-output?

Open Crare opened this issue 9 years ago • 3 comments

I get this output every time I run say() function

Playing WAVE '/tmp/tmplGOau7.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono

I want to disable that for easier debugging from console, when there is less stuff in the console it's easier to read. It would help if it didn't output anything else than what it's suppose to do: output sound from text that is given to it. Or at least have option for disabling it. If there is one I haven't found it or it's not mentioned in the docs or anywhere is it?

Crare avatar Jan 29 '17 11:01 Crare

I think it can be made quieter by adding a --quiet to this line: https://github.com/grigi/talkey/blob/master/talkey/base.py#L259 e.g. `cmd = ['aplay', '--quiet', str(filename)] And you are right, this should probably only ever show if debug logging is turned on.

grigi avatar Jan 30 '17 05:01 grigi

Is there any intention to fix this issue?

deepy avatar May 19 '17 13:05 deepy

I think it can be made quieter by adding a --quiet to this line: https://github.com/grigi/talkey/blob/master/talkey/base.py#L259 e.g. `cmd = ['aplay', '--quiet', str(filename)] And you are right, this should probably only ever show if debug logging is turned on.

Doesn't work for systems where that is not manually edited.

Hacky way to fix this by globally defaulting the subprocess.Popen not to output to stdout/stderr:

from talkey import Talkey

import subprocess
from functools import partial
subprocess.Popen = partial(  # type: ignore
    subprocess.Popen,
    stdout=subprocess.DEVNULL,
    stderr=subprocess.DEVNULL)

tts = Talkey()
tts.say("Hello world")

Another hacky way with automatic "unmuting" after the end of the SubprocessSilencer -block:

from talkey import Talkey

from typing import Any
from functools import partial
import subprocess
class SubprocessSilencer:
    def __enter__(self) -> None:
        self.popen = subprocess.Popen
        subprocess.Popen = partial(  # type: ignore
            subprocess.Popen,
            stdout=subprocess.DEVNULL,
            stderr=subprocess.DEVNULL)

    def __exit__(self, *args: Any) -> None:
        subprocess.Popen = self.popen  # type: ignore

tts = Talkey()
with SubprocessSilencer():
    tts.say("Hello world")

b10011 avatar Jul 12 '19 02:07 b10011