added printing elasped inference time
This commit is contained in:
parent
4f61f5c889
commit
7f8bd2b936
|
@ -7,6 +7,7 @@ import functools
|
||||||
|
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
|
|
||||||
|
from time import perf_counter
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from .inference import TTS
|
from .inference import TTS
|
||||||
|
@ -32,6 +33,14 @@ def gradio_wrapper(inputs):
|
||||||
return wrapped_function
|
return wrapped_function
|
||||||
return decorated
|
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):
|
def init_tts(restart=False):
|
||||||
global tts
|
global tts
|
||||||
|
|
||||||
|
@ -71,6 +80,7 @@ def do_inference( progress=gr.Progress(track_tqdm=True), *args, **kwargs ):
|
||||||
tmp = tempfile.NamedTemporaryFile(suffix='.wav')
|
tmp = tempfile.NamedTemporaryFile(suffix='.wav')
|
||||||
|
|
||||||
tts = init_tts()
|
tts = init_tts()
|
||||||
|
with timer() as t:
|
||||||
wav, sr = tts.inference(
|
wav, sr = tts.inference(
|
||||||
text=args.text,
|
text=args.text,
|
||||||
references=[args.references.split(";")],
|
references=[args.references.split(";")],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user