!! Japanese Only !!
No commits does not mean not maintained. If there's a problem, create an issue!
This is a self deployable Cloudflare Worker that serves as an audio source for Yomitan. Hosting it for yourself falls completely within the free limits of Cloudflare Workers. As an audio source it can be used from any device without having to run a local server or install an Anki-Addon or have any local storage used up. 1
Additionally it has extra features like pitch accent aware TTS and boasts the largest collection of Japanese audio available. Read more here: https://animecards.site/yomitan_audio/
If you want a no-hassle setup consider signing up for the $1 tier on the Patreon: https://www.patreon.com/quizmaster/membership. It saves you the trouble of setting up a Cloudflare and AWS account to enjoy all features. 🙂
- Ensure
npmandrcloneare installed on your system.
-
Create a Cloudflare account → https://dash.cloudflare.com/sign-up
-
Create a worker and select the "Hello World" template.
-
Name your worker
yomitan-audio-workerand deploy it. -
Go to
R2 Project Storagein the left sidebar and create a new bucket namedyomitan-audio-bucket. -
Go to
Storage & Database→D1 SQL Databaseand create a new database calledyomitan-audio-db.
-
Clone the repository and run the following commands:
npm installto install the dependencies.npx wrangler loginto authenticate with your Cloudflare account.
-
Copy
wrangler.toml.exampletowrangler.tomland replace thedatabase_identry with the ID of your previously created R2 bucket. Also adjust:AUTHENTICATION_ENABLEDif you want the endpoints to be protected by a password (STRONGLY RECOMMENDED).AWS_POLLY_ENABLEDif you want the pitch acccent TTS, as well as the AWS credentials with Polly access.
If you change these also run
npx wrangler typesto update the types. -
Copy
.dev.vars.exampleto.dev.varsand replace the following:API_KEYSwith a comma separated list of API keys that will be used to authenticate requests.- AWS credentials with Polly access.
-
Download the audio data and put it into the repository folder. MORE INFO ON DISCORD. (You should have a bunch of folders ending with
_filesindata.) -
Import the entries and pitch data into your D1 database by running the following command:
npx wrangler d1 execute yomitan-audio-db --remote --file=data/entry_and_pitch_db.sql
-
Go here and create an API Token to access your R2 bucket.
-
Upload the audio files to your R2 bucket by running the following command, replacing the placeholders with your own values from the previous step:
R2_ACCESS_KEY_ID="your_access_key" R2_SECRET_ACCESS_KEY="your_secret_key" R2_ACCOUNT_ID="your_cloudflare_account_id" bash scripts/upload-to-r2.sh
-
Upload the variables in
.dev.varsto Cloudflare by running the following command:npx wrangler secret put API_KEYSnpx wrangler secret put AWS_ACCESS_KEY_IDnpx wrangler secret put AWS_SECRET_ACCESS_KEY
-
Deploy the worker by running the following command:
npx wrangler deploy
-
Go to the Yomitan settings and set the
Audio Source URLto your worker URL andaudio/list?term={term}&reading={reading}&apiKey=yourApiKeyso for examplehttps://yomitan-audio-worker.friedrichde.workers.dev/audio/list?term={term}&reading={reading}&apiKey=m9NixGU7qtWv4SYr
Your worker should be up and running now and you getting unlimited Yomitan audio through your worker!
Footnotes
-
Note that you will still need to add a payment method to your Cloudflare account to create some rescoures, but you will not be charged for using this worker for yourself. ↩





