Skip to content
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
3 changes: 1 addition & 2 deletions zeeguu/core/audio_lessons/daily_lesson_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def prepare_lesson_generation(self, user, timezone_offset=0, suggestion=None, su
# Check if a lesson already exists for today
existing_lesson = self.get_todays_lesson_for_user(user, timezone_offset)
if existing_lesson.get("lesson_id"):
# If the user provided a topic that differs from the existing lesson's,
# delete the old lesson so a new one can be generated with the topic.
# If the suggestion changed, delete today's lesson and regenerate.
existing_topic = existing_lesson.get("suggestion")
existing_type = existing_lesson.get("suggestion_type")
topic_changed = suggestion and suggestion != existing_topic
Expand Down
58 changes: 58 additions & 0 deletions zeeguu/core/audio_lessons/prompts/meaning_lesson--situation-v1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Create a language learning audio script for the {target_language} word "{origin_word}" meaning "{translation_word}".
Note that the lesson is for somebody who is CEFR level {cefr_level} so ensure that sentences are of the appropriate difficulty.

The dialogue must be set in this real-world situation: "{suggestion}"
The characters should be in roles appropriate to the situation (e.g. a customer and waiter at a restaurant, a patient and doctor at a clinic, neighbors meeting on the stairway, etc). Choose realistic roles that fit the scenario naturally.

CRITICAL: The Teacher MUST speak {source_language} throughout the entire script. All teacher instructions, introductions, and challenges must be written in {source_language}. The Man and Woman speak {target_language}.

IMPORTANT: Output ONLY the script lines below. Do not include any explanations, preambles, or additional text.

Use this exact format:


Teacher: [Introduction in {source_language} setting the scene for the situation.
Explain who the characters are and what is happening. Mention they will hear the word:]
[0.2 seconds]
Man: {origin_word} [0.5 seconds]
Teacher: [Say "with the meaning" in {source_language}] [0.2 seconds]
Teacher: {translation_word}. [1 seconds]

Create a dialogue of at least 8 lines between Man and Woman using the target word naturally.
The dialogue must feel like a real conversation that would happen in the given situation.
In between lines add one second break annotations with: [1 seconds]



Next, add the teacher's voice with an introduction IN {source_language} inviting the listener
to practice speaking (similar to "Let's practice some key phrases" but in {source_language}).

Take each line of the dialogue again and after each line of dialogue make the teacher add
a challenge for the listener IN {source_language}. The challenge asks the listener to say
a phrase (diversify how the teacher formulates this):

Teacher: [Challenge in {source_language} asking "Could you say...?" or similar] [5 seconds]
Man: <target language phrase> [3 seconds]
Man: <repeat same phrase> [3 seconds]

Use as many challenges as possible from the dialogue.



Add a short introduction IN {source_language} (similar to "Let's practice more situations").

Do not use the origin word within this introduction.

Add 4 more similar challenges from the teacher IN {source_language}, but this time with
examples that do not relate to the dialogue, with commonly used contexts for the word.


RULES:
- Use only "Teacher:", "Man:", "Woman:" labels
- Include [X seconds] timing for pauses
- CRITICAL: Teacher MUST speak {source_language} for ALL lines. Man/Woman speak {target_language}
- For student response pauses, use [5 seconds] after teacher questions
- For repetitions, use [3 seconds] between repeats
- No explanatory text or translations in the script


58 changes: 58 additions & 0 deletions zeeguu/core/audio_lessons/prompts/meaning_lesson--topic-v1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Create a language learning audio script for the {target_language} word "{origin_word}" meaning "{translation_word}".
Note that the lesson is for somebody who is CEFR level {cefr_level} so ensure that sentences are of the appropriate difficulty.

The dialogue should revolve around the topic: "{suggestion}"
The examples and challenges should use vocabulary relevant to this topic.

CRITICAL: The Teacher MUST speak {source_language} throughout the entire script. All teacher instructions, introductions, and challenges must be written in {source_language}. The Man and Woman speak {target_language}.

IMPORTANT: Output ONLY the script lines below. Do not include any explanations, preambles, or additional text.

Use this exact format:


Teacher: [Introduction in {source_language} explaining that in the following conversation
they will hear a man and woman talking about {suggestion}. Mention they will hear the word:]
[0.2 seconds]
Man: {origin_word} [0.5 seconds]
Teacher: [Say "with the meaning" in {source_language}] [0.2 seconds]
Teacher: {translation_word}. [1 seconds]

Create a dialogue of at least 8 lines between Man and Woman using the target word naturally.
The dialogue should be themed around {suggestion}.
In between lines add one second break annotations with: [1 seconds]



Next, add the teacher's voice with an introduction IN {source_language} inviting the listener
to practice speaking (similar to "Let's practice some key phrases" but in {source_language}).

Take each line of the dialogue again and after each line of dialogue make the teacher add
a challenge for the listener IN {source_language}. The challenge asks the listener to say
a phrase (diversify how the teacher formulates this):

Teacher: [Challenge in {source_language} asking "Could you say...?" or similar] [5 seconds]
Man: <target language phrase> [3 seconds]
Man: <repeat same phrase> [3 seconds]

Use as many challenges as possible from the dialogue.



Add a short introduction IN {source_language} (similar to "Let's practice more situations").

Do not use the origin word within this introduction.

Add 4 more similar challenges from the teacher IN {source_language}, but this time with
examples that do not relate to the dialogue, with commonly used contexts for the word.


RULES:
- Use only "Teacher:", "Man:", "Woman:" labels
- Include [X seconds] timing for pauses
- CRITICAL: Teacher MUST speak {source_language} for ALL lines. Man/Woman speak {target_language}
- For student response pauses, use [5 seconds] after teacher questions
- For repetitions, use [3 seconds] between repeats
- No explanatory text or translations in the script


18 changes: 10 additions & 8 deletions zeeguu/core/audio_lessons/script_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,24 @@ def generate_lesson_script(
translation_language, translation_language
)

# Load and format the prompt
prompt_template = get_prompt_template(generator_prompt_file)
# Select template based on suggestion type
if suggestion and suggestion_type == "situation":
prompt_file = "meaning_lesson--situation-v1.txt"
elif suggestion and suggestion_type == "topic":
prompt_file = "meaning_lesson--topic-v1.txt"
else:
prompt_file = generator_prompt_file

prompt_template = get_prompt_template(prompt_file)
prompt = prompt_template.format(
origin_word=origin_word,
translation_word=translation_word,
target_language=origin_lang_name,
source_language=translation_lang_name,
cefr_level=cefr_level,
suggestion=suggestion or "",
)

if suggestion:
if suggestion_type == "situation":
prompt += f'\nSITUATION: Structure the lesson as a roleplay scenario: "{suggestion}". The dialogue should simulate a real conversation the learner might have in this situation.\n'
else:
prompt += f'\nTOPIC: Set the dialogue scenario in a context related to "{suggestion}". The examples and challenges should use vocabulary relevant to this topic.\n'

log(f"Generating script for {origin_word} -> {translation_word} (topic: {suggestion}, type: {suggestion_type})")

try:
Expand Down
Loading