added printing elasped inference time

This commit is contained in:
mrq 2023-09-09 20:05:03 -05:00
parent 4f61f5c889
commit 7f8bd2b936

View File

@ -7,6 +7,7 @@ import functools
import gradio as gr
from time import perf_counter
from pathlib import Path
from .inference import TTS
@ -32,6 +33,14 @@ def gradio_wrapper(inputs):
return wrapped_function
return decorated
class timer:
def __enter__(self):
self.start = perf_counter()
return self
def __exit__(self, type, value, traceback):
print(f'Elapsed time: {(perf_counter() - self.start):.3f}s')
def init_tts(restart=False):
global tts
@ -71,6 +80,7 @@ def do_inference( progress=gr.Progress(track_tqdm=True), *args, **kwargs ):
tmp = tempfile.NamedTemporaryFile(suffix='.wav')
tts = init_tts()
with timer() as t:
wav, sr = tts.inference(
text=args.text,
references=[args.references.split(";")],