Turns a Japanese source text (e.g., a novel) into listening-first study material: sentence-aligned Japanese/English pairs, plus optional short “micro-breakdowns” (up to three per sentence). Some sentences may also include an optional “literal” English line to make the Japanese structure easier to see.
The pipeline: clean + split the raw text into manageable chunks → translate sentence-by-sentence with batch context (optionally adding micro-breakdowns + a literal line) → generate per-sentence audio files you can play like an “audiobook” with JP/EN pairs (plus optional breakdown/literal audio).
- Input:
jp.txt - Output:
divided_output.txt - Cleans the text first by removing ruby/furigana and transcription markup (e.g.,
《...》,|,[#...]). - Splits the text into paragraphs (blank-line separated), then groups paragraphs into batches capped by
MAX_CHARS_PER_BATCH(andMAX_PARAGRAPHS_PER_BATCH). - If a paragraph is too long, it is split at Japanese sentence boundaries first, then by line breaks, then by character-count as a fallback.
- Batches in the output are separated by
---(specifically\n\n---\n\n).
- Input:
divided_output.txt - Output:
translated_output.json(+ incrementaltranslation_progress.json) - For each batch: splits into sentences and numbers them, then sends them together for contextual translation. Sentence splitting tries not to break inside Japanese quotes like
「...」/『...』. - Expects a JSON array with fields:
sentence_number,english, optionalenglish_literal, and up to 3 optional breakdown pairs:part_to_breakdown_1..3andbreakdown_1..3. - Micro-breakdowns are meant to be short: each one pairs a JP phrase (
part_to_breakdown_*) with a brief English explanation (breakdown_*). - Saves the final output as a dict with
metadataplus asentencesobject keyed by global sentence index (each entry includesjapanese,english, optionalenglish_literal,batch_number, and breakdown fields). - Reads API settings from
config.json(or environment variables), with basic retry/backoff.
- Input:
translated_output_part.json - Output folder:
audio_sentences/ - Uses Balabolka
bal4web.exewith Microsoft voices; auto-detects working JA male/female voices and tries to find an EN voice. - Generates audio per sentence as MP3s (WAVs are generated as intermediates and then converted/cleaned up).
- Generates multiple segments per sentence (where possible): sentence number (JP), Japanese sentence (male), English translation, combined breakdown audio (up to 3 JP terms + EN notes), optional literal-English audio, and an alternating JP female→male version.
- Uses configurable pauses/silence and per-segment speech-rate settings; retries transient TTS failures.
jp.txt— example input Japanese text (No Longer Human / 人間失格 by Osamu Dazai)divided_output.txt— example output fromdivide.pytranslated_output.json— example output fromdeepseek_breakdown.py
- This repo is not actively maintained.
- Upload the scripts to an AI assistant if you want a deeper, line-by-line explanation.
GPL.