Added option for server ui details page.

This commit is contained in:
Thorsten Mueller 2021-01-20 21:56:40 +01:00
parent b70bef579a
commit e414582be6
2 changed files with 149 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import os
from flask import Flask, request, render_template, send_file
from TTS.server.synthesizer import Synthesizer
from TTS.utils.io import load_config
def create_argparser():
@ -23,6 +24,7 @@ def create_argparser():
parser.add_argument('--port', type=int, default=5002, help='port to listen on.')
parser.add_argument('--use_cuda', type=convert_boolean, default=False, help='true to use CUDA.')
parser.add_argument('--debug', type=convert_boolean, default=False, help='true to enable Flask debug mode.')
parser.add_argument('--show_details', type=convert_boolean, default=False, help='Generate model detail page.')
return parser
@ -69,6 +71,22 @@ app = Flask(__name__)
def index():
return render_template('index.html')
@app.route('/details')
def details():
if args.tts_config is not None and os.path.isfile(args.tts_config):
taco2_config = load_config(args.tts_config)
if args.vocoder_config is not None and os.path.isfile(args.vocoder_config):
vocoder_config = load_config(args.vocoder_config)
else:
vocoder_config = None
return render_template('details.html',
show_details=args.show_details
, taco2_config=taco2_config
, vocoder_config=vocoder_config
, args=args.__dict__
)
@app.route('/api/tts', methods=['GET'])
def tts():

View File

@ -0,0 +1,131 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>TTS engine</title>
<!-- Bootstrap core CSS -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css"
integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous"
rel="stylesheet">
<!-- Custom styles for this template -->
<style>
body {
padding-top: 54px;
}
@media (min-width: 992px) {
body {
padding-top: 56px;
}
}
</style>
</head>
<body>
<a href="https://github.com/mozilla/TTS"><img style="position: absolute; z-index:1000; top: 0; left: 0; border: 0;"
src="https://s3.amazonaws.com/github/ribbons/forkme_left_darkblue_121621.png" alt="Fork me on GitHub"></a>
{% if show_details == true %}
<div class="container">
<b>Model details</b>
</div>
<div class="container">
<details>
<summary>CLI arguments:</summary>
<table border="1" align="center" width="75%">
<tr>
<td> CLI key </td>
<td> Value </td>
</tr>
{% for key, value in args.items() %}
<tr>
<td>{{ key }}</td>
<td>{{ value }}</td>
</tr>
{% endfor %}
</table>
</details>
</div></br>
<div class="container">
{% if taco2_config != None %}
<details>
<summary>Tacotron2 model config:</summary>
<table border="1" align="center" width="75%">
<tr>
<td> Key </td>
<td> Value </td>
</tr>
{% for key, value in taco2_config.items() %}
<tr>
<td>{{ key }}</td>
<td>{{ value }}</td>
</tr>
{% endfor %}
</table>
</details>
{% endif %}
</div></br>
<div class="container">
{% if vocoder_config != None %}
<details>
<summary>Vocoder model config:</summary>
<table border="1" align="center" width="75%">
<tr>
<td> Key </td>
<td> Value </td>
</tr>
{% for key, value in vocoder_config.items() %}
<tr>
<td>{{ key }}</td>
<td>{{ value }}</td>
</tr>
{% endfor %}
</table>
</details>
{% endif %}
</div></br>
{% else %}
<div class="container">
<b>Please start server with --show_details=true to see details.</b>
</div>
{% endif %}
</body>
</html>