Audio language lesson generator (MP3) inspired by the Pimsleur methodology. Use AI to create custom dialogues and transform them into interactive lessons with spaced repetition. If you would like to use another TTS engine, please refer to edge-tts.
Maybe you wish a more professional already created course. In this case, you should consider buying Pimsleur's courses.
Prepare the virtual environment and dependencies:
./setup.shOr manually:
python -m pip install -r requirements.txtor
./python3/bin/python -m pip install -r requirements.txtThe p2c.py script has two main modes: Generate Prompt (to request lesson content from an AI) and Generate Audio (to transform the AI's JSON into an MP3).
The script generates a structured prompt in English (for better performance with global models like GPT-4 and Gemini) based on your theme and level.
Command:
./python3/bin/python p2c.py --theme "Checking into a hotel" --level A2or
./python3/bin/python p2c.py --theme "Checking into a hotel" --level A2 --native en_us --target pt_brOptional Parameters:
--native: Your native language (default:pt_br).--target: Language you want to learn (default:en_us).
What to do:
- Copy the text generated in the terminal.
- Paste it into your favorite AI chat (ChatGPT, Gemini, Claude, etc).
- Save the JSON returned by the AI into a file (e.g.,
lesson.json).
Transform the JSON returned by the AI into a narrated lesson. You can either pass a file path or the JSON string directly.
Using a file:
./python3/bin/python p2c.py --file lesson.jsonUsing a JSON string:
./python3/bin/python p2c.py --json '{"pt_br": [...], "en_us": [...], "target_words_pt_br": [...], "target_words_en_us": [...], "voices": {...}}'Full example with language flags:
./python3/bin/python p2c.py --file lesson.json --native en_us --target pt_brOptional Parameters:
--native: Must be the same native language used in the JSON (default:pt_br).--target: Must be the same target language used in the JSON (default:en_us).
The narrator's instructions during the lesson are translated in the translations.json file. Currently, we support:
- 🇧🇷 Brazilian Portuguese (
pt_br) - 🇺🇸 American English (
en_us)
Below are some ideas for you to use with the --theme flag:
- "Asking for directions to reach the train station."
- "Going through immigration and explaining the reason for the trip."
- "Asking for the bill and if they accept cards."
- "Rescheduling a last-minute meeting with a client."
- "Introducing yourself on the first day of work."
- "Negotiating project delivery deadlines."
- "Inviting a colleague for coffee on Friday."
- "Politely complaining to a neighbor about loud noise."
- "Discussing the plot of a movie they just watched."
The script processes the JSON and creates a dynamic audio lesson:
- Listening: You hear the full conversation between native speakers.
- Construction: The narrator guides you sentence by sentence ("How do you say: ...?").
- Vocabulary: Special focus on target words (
target_words) identified in the lesson. - Spaced Repetition: The script alternates between new sentences and constant reviews of previous items for reinforcement.
- Duration: The lesson ends automatically after reaching a satisfactory repetition level.
If you want to create the file manually, it should follow this format:
{
"pt_br": [
{ "person_1": "Olá, como você está?" },
{ "person_2": "Eu estou bem, obrigado!" }
],
"en_us": [
{ "person_1": "Hello, how are you?" },
{ "person_2": "I am fine, thank you!" }
],
"target_words_pt_br": ["bem", "obrigado"],
"target_words_en_us": ["fine", "thank you"],
"voices": {
"narrator": "pt-BR-AntonioNeural",
"person_1": "en-US-JennyNeural",
"person_2": "en-US-GuyNeural"
}
}