Add --max-text-length to mimic3-server
This commit is contained in:
parent
938b5eff70
commit
05795c5d82
3 changed files with 18 additions and 2 deletions
|
|
@ -153,7 +153,11 @@ def get_app(args: argparse.Namespace, request_queue: Queue, temp_dir: str):
|
|||
@app.route("/")
|
||||
async def app_index():
|
||||
"""Main page."""
|
||||
return await render_template("index.html", show_openapi=show_openapi)
|
||||
return await render_template(
|
||||
"index.html",
|
||||
show_openapi=show_openapi,
|
||||
max_text_length=args.max_text_length,
|
||||
)
|
||||
|
||||
@app.route("/api/tts", methods=["GET", "POST"])
|
||||
async def app_tts() -> Response:
|
||||
|
|
@ -206,6 +210,9 @@ def get_app(args: argparse.Namespace, request_queue: Queue, temp_dir: str):
|
|||
|
||||
assert text, "No text provided"
|
||||
|
||||
if args.max_text_length is not None:
|
||||
text = text[: args.max_text_length]
|
||||
|
||||
# Cache settings
|
||||
no_cache_str = request.args.get("noCache", "")
|
||||
no_cache = _to_bool(no_cache_str)
|
||||
|
|
@ -237,6 +244,9 @@ def get_app(args: argparse.Namespace, request_queue: Queue, temp_dir: str):
|
|||
text = request.args.get("INPUT_TEXT", "")
|
||||
voice = str(request.args.get("VOICE", voice)).strip()
|
||||
|
||||
if args.max_text_length is not None:
|
||||
text = text[: args.max_text_length]
|
||||
|
||||
voice = voice or args.voice or DEFAULT_VOICE
|
||||
|
||||
# Assume SSML if text begins with an angle bracket
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue