Skip to content

Commit

Permalink
impl. speed range, fix speed example, increase expiration, removal an…
Browse files Browse the repository at this point in the history
…d timeout lengths
  • Loading branch information
rlellep committed Nov 21, 2022
1 parent 72b7ea4 commit 87bc571
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
4 changes: 3 additions & 1 deletion app/api/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ async def create_job(response: Response,
speed: float = Form(default=1.0),
session: AsyncSession = Depends(database.get_session)):
if file.content_type != "application/epub+zip":
raise HTTPException(400, "Unsupported file type")
raise HTTPException(400, "Unsupported file type.")
if speed < 0.5 or speed > 2.0:
raise HTTPException(400, "Parameter 'speed' out of range.")

if not FILENAME_RE.fullmatch(file.filename):
LOGGER.debug(f"Bad filename: {file.filename}")
Expand Down
4 changes: 2 additions & 2 deletions app/api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class JobInfo(BaseModel):
description="Speaker voice to synthesize with",
example=Speaker.Mari)
speed: float = Field(...,
description="Speed to synthesize with.",
example=Speaker.Mari)
description="Speed to synthesize with (in range 0.5-2.0).",
example=1.0)
file_name: str = Field(...,
description="Original name of the uploaded file",
example="book.epub")
Expand Down
6 changes: 3 additions & 3 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class APISettings(BaseSettings):
username: str = 'guest'
password: str = 'guest'
cleanup_interval: int = 600 # 10 minutes - run db & file cleanup
expiration_threshold: int = 6000 # 100 minutes - expire / cancel jobs without updates
removal_threshold: int = 86400 # 24 h - remove db records after expiration / cancellation
expiration_threshold: int = 605_000 # one week - expire / cancel jobs without updates
removal_threshold: int = 605_000 # one week - remove db records after expiration / cancellation

storage_path: str = './data'

Expand All @@ -21,7 +21,7 @@ class MQSettings(BaseSettings):
username: str = 'guest'
password: str = 'guest'
exchange: str = 'epub_to_audiobook'
timeout: int = 1200 # 20 minutes
timeout: int = 605_000 # one week - remove not consumed jobs from queue

class Config:
env_prefix = 'mq_'
Expand Down
7 changes: 6 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
- '5672:5672'
mysql:
image: 'mysql:8.0.27'
command: --max_allowed_packet=2685000000
restart: unless-stopped
environment:
- MYSQL_USER=${MYSQL_USER}
Expand Down Expand Up @@ -47,9 +48,13 @@ services:
- MQ_PORT=5672
- MQ_USERNAME=${RABBITMQ_USER}
- MQ_PASSWORD=${RABBITMQ_PASS}
- HTTP_HOST=localhost
- EPUB_HOST=${HTTP_HOST}
- EPUB_PORT=${HTTP_PORT}
- HTTP_USERNAME=${API_USER}
- HTTP_PASSWORD=${API_PASS}
- TTS_HOST=api.tartunlp.ai
- TTS_PORT=443
- TTS_PROTOCOL=https
depends_on:
- rabbitmq
restart: unless-stopped
Expand Down
4 changes: 2 additions & 2 deletions sample.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MQ_PORT=5672
MQ_HOST=192.168.32.1
HTTP_PORT=80
HTTP_HOST=172.19.0.1
RABBITMQ_USER=guest
RABBITMQ_PASS=guest
MYSQL_USER=guest
Expand Down

0 comments on commit 87bc571

Please sign in to comment.