Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve dev documentation #20

Merged
merged 2 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .envrc.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# export WATTS_API_KEY=

# Bucket to use for caching audio files. Required.
export WATTS_BUCKET=mbta-audio-service-test
export WATTS_BUCKET=mbta-watts-staging

# AWS credentials. Required.
# export AWS_ACCESS_KEY_ID=
Expand Down
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,27 @@ MBTA text-to-speech service

* Run `asdf install` from the repository root.
* `mix deps.get` to fetch dependencies.
* Copy `.envrc.template` to `.envrc`, then edit `.envrc` and make sure all required environment variables are set. When finished, run `direnv allow` to activate them.
* Copy `.envrc.template` to `.envrc`, then edit `.envrc` and make sure all
required environment variables are set. When finished, run `direnv allow` to
activate them.
* To start the server, run `iex -S mix`.

**Note:** There is no automatic code reloading in development. To pick up code
changes while the server is running, use the `recompile` command in IEx.

## API

The main API endpoint is `/tts`, which accepts JSON POST requests containing
`voice_id` and `text` fields. An `x-api-key` HTTP header must also be set to
the value specified in the `WATTS_API_KEY` environment variable.

Example request, using `curl` and a local development instance of the app:

curl localhost:4000/tts \
--output voice.mp3 \
--header "x-api-key: your_api_key_here" \
--json '{"voice_id": "Matthew", "text": "<speak>Your text here.</speak>"}'

Note to synthesize new (uncached) voice lines, the `WATTS_ENABLE_POLLY`
environment variable must be `true`. **This incurs a cost per character of
text**, so avoid large amounts of text or a large number of unique lines.
Loading