diff --git a/mimic3-http/MANIFEST.in b/mimic3-http/MANIFEST.in index fdd79b2..9c35dc9 100644 --- a/mimic3-http/MANIFEST.in +++ b/mimic3-http/MANIFEST.in @@ -3,3 +3,4 @@ include requirements_dev.txt include LICENSE include README.md include mimic3_http/VERSION +include mimic3_http/swagger.yaml diff --git a/mimic3-http/mimic3_http/app.py b/mimic3-http/mimic3_http/app.py index 2932f7a..b774c3d 100644 --- a/mimic3-http/mimic3_http/app.py +++ b/mimic3-http/mimic3_http/app.py @@ -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.""" diff --git a/mimic3-http/mimic3_http/swagger.yaml b/mimic3-http/mimic3_http/swagger.yaml new file mode 100644 index 0000000..35d9c69 --- /dev/null +++ b/mimic3-http/mimic3_http/swagger.yaml @@ -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 /_ optional with # 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 diff --git a/mimic3-http/mimic3_http/templates/index.html b/mimic3-http/mimic3_http/templates/index.html index 268c5ab..cc6a02f 100644 --- a/mimic3-http/mimic3_http/templates/index.html +++ b/mimic3-http/mimic3_http/templates/index.html @@ -54,6 +54,8 @@
+

+ API
diff --git a/mimic3-http/requirements.txt b/mimic3-http/requirements.txt index 7dd160a..f06a577 100644 --- a/mimic3-http/requirements.txt +++ b/mimic3-http/requirements.txt @@ -2,3 +2,4 @@ mimic3-tts<1.0 quart>=0.16,<1.0 quart-cors requests>=2,<3 +swagger-ui-py>=21,<22 diff --git a/mimic3-http/setup.py b/mimic3-http/setup.py index 0c1782f..7bf5047 100644 --- a/mimic3-http/setup.py +++ b/mimic3-http/setup.py @@ -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=[