Skip to content

Commit

Permalink
fix speed parameter type; other minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
liisaratsep committed Dec 16, 2022
1 parent f3fa8f8 commit 6739c95
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# Extra
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}ct metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
Expand All @@ -55,8 +57,6 @@ jobs:
latest=${{ !github.event.release.prerelease }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_LOWER }}

- name: Set up Docker Buildx
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
An API based on FastAPI for using neural text-to-speech synthesis. The API is designed to be used together with our
[text-to-speech workers](https://github.com/TartuNLP/text-to-speech-worker).

The project is developed by the [NLP research group](https://tartunlp.ai) at the [Universty of Tartu](https://ut.ee).
The project is developed by the [NLP research group](https://tartunlp.ai) at the [University of Tartu](https://ut.ee).
Speech synthesis can also be tested in our [web demo](https://www.neurokone.ee/).

## API usage
Expand Down Expand Up @@ -32,7 +32,7 @@ in `.wav` format.

The API forwards requests to various TTS engines using the RabbitMQ message broker. The communication uses a direct
exchange named `text-to-speech` and a routing key of the request parameters using the format `text-to-speech.$speaker`.
TTS workers estabilish queues within the exchange that are bound routing keys that illustrate which requests that the
TTS workers establish queues within the exchange that are bound routing keys that illustrate which requests that the
particular model can handle.

## Setup
Expand Down Expand Up @@ -60,7 +60,7 @@ The following environment variables should be specified when running the contain
The entrypoint of the container
is `["uvicorn", "app:app", "--host", "0.0.0.0", "--proxy-headers", "--log-config", "config/logging.ini"]`.

The `CMD` option can be used to override flags in the entrypoint or to overridde
The `CMD` option can be used to override flags in the entrypoint or to override
different [Uvicorn parameters](https://www.uvicorn.org/deployment/). For example,
`["--log-config", "config/logging.debug.ini", "--root-path", "/text-to-speech"]` enables debug logging and allows the API
to be mounted under to the non-root path `/text-to-speech` when using a proxy server such as Nginx.
Expand Down
1 change: 0 additions & 1 deletion app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from .tts import v2_router

logger = logging.getLogger(__name__)
logger.warning(api_settings)

app = FastAPI(title="Text-to-Speech API",
version=api_settings.version if api_settings.version else "dev",
Expand Down
6 changes: 3 additions & 3 deletions app/mq_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


def uuid4():
"""Cryptographycally secure UUID generator."""
"""Cryptographically secure UUID generator."""
return uuid.UUID(bytes=os.urandom(16), version=4)


Expand Down Expand Up @@ -51,7 +51,7 @@ async def on_response(self, message: AbstractIncomingMessage):
if message.correlation_id in self.futures:
body = json.loads(message.body.decode())
if body['status_code'] != 200:
LOGGER.info(f"Received erronous response for request: {{"
LOGGER.info(f"Received erroneous response for request: {{"
f"id: {message.correlation_id}, "
f"code: {body['status_code']}}}")
future = self.futures.pop(message.correlation_id, None)
Expand Down Expand Up @@ -102,7 +102,7 @@ async def publish_request(self, body: BaseModel, speaker: str) -> Tuple[dict, st
raise HTTPException(408)

if worker_response['status_code'] != 200:
LOGGER.info(f"Received erronous response for request: {{"
LOGGER.info(f"Received erroneous response for request: {{"
f"id: {correlation_id}, "
f"code: {worker_response['status_code']}}}")
raise HTTPException(worker_response['status_code'], detail=worker_response['status'])
Expand Down
11 changes: 9 additions & 2 deletions app/tts/v2_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ async def get_config():
@v2_router.post('', response_class=Response,
description="Submit a text-to-speech request.",
responses={
200: {"content": {"audio/wav": {}}, "description": "Returns the synthesized audio."},
422: {"model": ErrorMessage},
200: {"content": {"audio/wav": {}}, "description": "Returns the synthesized audio."}
408: {"model": ErrorMessage},
500: {"model": ErrorMessage}
})
async def synthesis(body: Request):
content, correlation_id = await mq_connector.publish_request(body, body.speaker)
Expand All @@ -44,7 +46,12 @@ async def synthesis(body: Request):

@v2_router.post('/verbose', response_model=ResponseContent,
description="Submit a text-to-speech request and return only some information about the output.",
responses={422: {"model": ErrorMessage}, 200: {"model": ResponseContent}})
responses={
200: {"content": {"audio/wav": {}}, "description": "Returns the synthesized audio."},
422: {"model": ErrorMessage},
408: {"model": ErrorMessage},
500: {"model": ErrorMessage}
})
async def synthesis_info(body: Request):
content, correlation_id = await mq_connector.publish_request(body, body.speaker)
return content
2 changes: 1 addition & 1 deletion app/tts/v2_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Request(BaseModel):
speaker: str = Field(...,
example="mari",
description="Name of speaker (not case-sensitive).")
speed: int = Field(default=1,
speed: float = Field(default=1,
description="Output audio speed multiplier.",
ge=0.5,
le=2)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
aio-pika==8.2.5
fastapi==0.87.0
fastapi==0.88.0
uvicorn==0.20.0
pydantic~=1.10.2
pyyaml==6.0
Expand Down

0 comments on commit 6739c95

Please sign in to comment.