Add OpenAPI page
This commit is contained in:
parent
33ea9c086d
commit
746fa228cf
6 changed files with 67 additions and 2 deletions
|
|
@ -3,3 +3,4 @@ include requirements_dev.txt
|
|||
include LICENSE
|
||||
include README.md
|
||||
include mimic3_http/VERSION
|
||||
include mimic3_http/swagger.yaml
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ from quart import (
|
|||
request,
|
||||
send_from_directory,
|
||||
)
|
||||
from swagger_ui import api_doc
|
||||
|
||||
from ._resources import _DIR, _PACKAGE
|
||||
from .args import _MISSING
|
||||
|
|
@ -273,6 +274,11 @@ def get_app(args: argparse.Namespace, mimic3: Mimic3TextToSpeechSystem, temp_dir
|
|||
|
||||
return Response(wav_bytes, mimetype="audio/wav")
|
||||
|
||||
# Swagger UI
|
||||
api_doc(
|
||||
app, config_path=_DIR / "swagger.yaml", url_prefix="/openapi", title="Mimic 3"
|
||||
)
|
||||
|
||||
@app.errorhandler(Exception)
|
||||
async def handle_error(err) -> typing.Tuple[str, int]:
|
||||
"""Return error as text."""
|
||||
|
|
|
|||
46
mimic3-http/mimic3_http/swagger.yaml
Normal file
46
mimic3-http/mimic3_http/swagger.yaml
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
openapi: "3.0.0"
|
||||
info:
|
||||
title: 'Mimic 3'
|
||||
version: '0.1'
|
||||
description: 'A fast and local neural text to speech system for Mycroft'
|
||||
schemes:
|
||||
- http
|
||||
servers:
|
||||
- url: http://localhost:59125
|
||||
description: Local server
|
||||
paths:
|
||||
/api/tts:
|
||||
get:
|
||||
summary: 'Speak text to WAV'
|
||||
parameters:
|
||||
- in: query
|
||||
name: voice
|
||||
required: true
|
||||
description: 'Voice in the form <lang>/<name>_<quality> optional with #<speaker> at the end'
|
||||
schema:
|
||||
type: string
|
||||
example: 'en_UK/apope_low'
|
||||
- in: query
|
||||
name: text
|
||||
required: true
|
||||
description: 'Text to speak'
|
||||
schema:
|
||||
type: string
|
||||
example: 'Welcome to the world of speech synthesis!'
|
||||
produces:
|
||||
- audio/wav
|
||||
responses:
|
||||
'200':
|
||||
description: audio
|
||||
schema:
|
||||
type: binary
|
||||
/api/voices:
|
||||
get:
|
||||
summary: 'Get available voices'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
'200':
|
||||
description: voices
|
||||
schema:
|
||||
type: object
|
||||
|
|
@ -54,6 +54,8 @@
|
|||
</div>
|
||||
<div class="col-auto">
|
||||
<button id="speak-button" name="speak" class="btn btn-lg btn-primary" alt="Generate speech">Speak</button>
|
||||
<br/><br />
|
||||
<a href="/openapi/" title="OpenAPI page" target="_blank" class="badge badge-info">API</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-3">
|
||||
|
|
|
|||
|
|
@ -2,3 +2,4 @@ mimic3-tts<1.0
|
|||
quart>=0.16,<1.0
|
||||
quart-cors
|
||||
requests>=2,<3
|
||||
swagger-ui-py>=21,<22
|
||||
|
|
|
|||
|
|
@ -80,13 +80,22 @@ setup(
|
|||
author_email="michael.hansen@mycroft.ai",
|
||||
license="AGPLv3+",
|
||||
packages=setuptools.find_packages(),
|
||||
package_data={"mimic3_http": ["VERSION", "py.typed", "templates", "css", "img"]},
|
||||
package_data={
|
||||
"mimic3_http": [
|
||||
"VERSION",
|
||||
"py.typed",
|
||||
"templates",
|
||||
"css",
|
||||
"img",
|
||||
"swagger.yaml",
|
||||
]
|
||||
},
|
||||
install_requires=requirements,
|
||||
extras_require={':python_version<"3.9"': ["importlib_resources"], **extras_require},
|
||||
entry_points={
|
||||
"console_scripts": [
|
||||
"mimic3-server = mimic3_http.__main__:main",
|
||||
"mimic3-client = mimic3_http.client.__main__:main",
|
||||
"mimic3-client = mimic3_http.client:main",
|
||||
]
|
||||
},
|
||||
classifiers=[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue