- Sample script for "Learn Japanese🇯🇵 with Python🐍"
- OpenAI works by default. Just set
OPENAI_API_KEYin a.envfile and run. - Dependencies are provider-agnostic via IoC (Inversion of Control). You can switch providers without code changes.
- Optional: Set up credentials if you want DeepL/AWS Polly
Use a .env file (recommended):
$ cp .env.example .env
$ vi .env # fill in OPENAI_API_KEY (and others if desired)- Run sample script
$ python3.12 -m venv env
$ . env/bin/activate
(env) pip install -r requirements.txt
(env) streamlit run learn_jp.pyOpenAI is the default provider. Configure via .env (defaults shown):
# Translation: openai | deepl | libre | none
TRANSLATOR_PROVIDER=openai
# OpenAI Translation
OPENAI_API_KEY=...
OPENAI_TRANSLATION_MODEL=gpt-4o-mini
LIBRE_TRANSLATE_URL=https://libretranslate.com
# Text-to-speech: openai | polly | noop
TTS_PROVIDER=openai
# OpenAI TTS
OPENAI_TTS_MODEL=gpt-4o-mini-tts
OPENAI_TTS_VOICE=alloy
# Optional Polly voice when using polly
TTS_VOICE=Mizuki- DeepL and Amazon Polly providers have not been fully tested in this branch. If they don't work for you, switch back to OpenAI or revert to a previous commit where DeepL and Polly were the default providers for the streamlit app.
If you configure DeepL and Polly, set:
export DEEPL_API_KEY=...
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_DEFAULT_REGION=ap-northeast-1