Yujing (语境): Dynamic AI Sentences and Native Audio

AnkiWeb addon 588397935

Generates fresh OpenAI example sentences and MP3 audio in the background during review, automatically highlights target words, and supports configurable note fields, models, voices, and prompts.
AI-generated summary; may contain mistakes.

card-creationaireview-flowformatting

Open on AnkiWeb GitHub Find alternatives

AnkiWeb

Votes
0 (👍 0 · 👎 0)
Updated
2026-04-08
Anki versions
2.1.1~
License
AGPL-3.0 (from the license file in the package)
Virus scan
No ClamAV match A match does not prove malware. No match does not prove that the code is safe.
Languages
Python, JSON
Description language
en

Maintenance

stale

  • Last update or commit: 2026-04-08 (207 days before the snapshot).
  • Commits in the last year: 10.
  • Issues: 0 open, 0 closed.
  • Pull requests: 0 open, 0 merged.

Will it work on my Anki?

Version branches
Min AnkiMax AnkiUpdated
2.1.1+2026-04-08
History across monthly snapshots

Loading…

Similar addons

Anki AI Dynamic Cards Add-on (AI generated examples)

Generates fresh AI example sentences on the fly for simple English word or phrase cards, supports multiple AI providers, and stores nothing in your collection.

ai

5 votes 23% approval 👍 3 · 👎 2 ⭐ 4 Anki 2.1.66~ Updated 2025-12-24
AI Language Explainer

Generates contextual written explanations and spoken audio for target words in sentence cards using OpenAI models and selectable TTS engines, with one-click or batch processing.

card-creationaisync-integrationdictionary

10 votes 72% approval 👍 10 · 👎 0 ⭐ 9 Anki 2.1.66~ Updated 2025-10-07

Description

Yujing (语境): AI Example Sentence and Audio Generator

Yujing (语境) is an Anki add-on designed to provide dynamic context for language learners. It utilizes the OpenAI API to generate new example sentences and corresponding audio for specific cards during the review process. This prevents the "stagnation" of seeing the same example sentence repeatedly, ensuring that each time a word is reviewed, it is presented in a fresh context.

Functionality

  • Background Generation: Sentence and audio generation occurs in a background thread triggered when you answer "Good" or "Easy" (Ease score 3 or 4). This allows you to continue your review session without interruption.
  • i+1 Principle: The system is designed to generate sentences using simple vocabulary that a learner would already know, ensuring the target word is the only "new" element.
  • Text-to-Speech (TTS): Uses OpenAI’s audio/speech endpoint to generate high-fidelity MP3 files, saved directly to your Anki media folder.
  • Automatic Highlighting: The add-on identifies the target word within the new sentence and applies <b> tags for visual clarity automatically.

Configuration & Setup

To enable Yujing, you must configure your Note Type and the add-on settings via Tools > Yujing Settings.

1. Required Note Fields

The Note Type you are using must include these three specific fields for the add-on to write data:

  • Generated Sentence: The AI-generated example.
  • Generated Translation: The translation of the new example.
  • Generated Audio: The [sound:...] tag for the generated speech.

2. Settings Overview

  • API Key: Your OpenAI secret key.
  • Target Word Field: The name of the field containing the word you are learning (e.g., "Word" or "Expression").
  • Model: Supports models like gpt-4o-mini (optimized for speed/cost) or gpt-4o.
  • Audio Voice: Choose from OpenAI's neural voices: alloy, echo, fable, onyx, nova, shimmer.

3. Prompt Placeholders

The Prompt Template allows you to customize the AI's instructions. You must use the following placeholders to map card data correctly:

  • {Target}: The word from your target field.
  • {Generated Sentence}: The existing sentence on the card (helps the AI provide a different context).
  • {Generated Translation}: The existing translation.

Card Template Example

Paste the following logic into your Back Template. This logic displays the AI-generated content if it exists, otherwise it falls back to your original deck content.


<!-- AI-Generated Section -->
{{#Generated Sentence}}
  <div class="ai-sentence">{{Generated Sentence}}</div>
  <div class="ai-translation">{{Generated Translation}}</div>
  <hr />
{{/Generated Sentence}}

<!-- Original Content Fallback -->
{{^Generated Sentence}}
  <div class="original-sentence">{{Sentence}}</div>
  <div class="original-translation">{{Translation}}</div>
  <hr />
{{/Generated Sentence}}

<!-- Audio Handling -->
<div class="media">
  {{#Generated Audio}}
    {{Generated Audio}}
  {{/Generated Audio}}
  {{^Generated Audio}}
    {{SentenceAudio}}
  {{/Generated Audio}}
</div>

Development and Support

Note: Accuracy of translations and sentences is dependent on the AI model selected. Users are responsible for their own OpenAI API usage costs.

README

Yujing (语境)

AI-Powered Example Sentence and Audio Generator for Anki

Yujing (语境) is an Anki add-on designed to provide dynamic context for language learners. It utilizes the OpenAI API to generate new example sentences and corresponding audio for specific cards during the review process. This prevents the "stagnation" of seeing the same example sentence repeatedly, ensuring that each time a word is reviewed, it is presented in a fresh context.


Core Features

  • Background Generation: Sentence and audio generation occurs in a background thread. This allows the user to continue their review session without waiting for the API response.
  • i+1 Principle: The default prompt instructs the AI to generate sentences using simple vocabulary, ensuring that the target word is the only unfamiliar element in the sentence.
  • Text-to-Speech (TTS): The add-on uses OpenAI’s audio/speech endpoint to generate high-quality MP3 files, which are saved to the Anki media folder and linked to the card.
  • Automatic Highlighting: The add-on identifies the target word within the new sentence and applies <b> tags automatically for visual clarity.
  • Configurable Settings: Users can modify the API endpoint, model (e.g., GPT-4o-mini), prompt template, and TTS voice (e.g., Alloy, Nova) via the settings menu.

Technical Requirements

Required Fields

For this add-on to function, the Note Type being used must include the following three fields:

  1. Generated Sentence
  2. Generated Translation
  3. Generated Audio

API Access

An OpenAI API Key with a positive account balance is required. Users are responsible for their own API usage costs.


Card Template Integration

To display the generated content on your cards with a fallback to your original deck's content, add the following logic to your Back Template:

{{#Generated Sentence}}
  <div class="ai-sentence">{{Generated Sentence}}</div>
  <div class="ai-translation">{{Generated Translation}}</div>
  <hr />
{{/Generated Sentence}}

{{^Generated Sentence}}
  <div class="original-sentence">{{Sentence}}</div>
  <div class="original-translation">{{Translation}}</div>
  <hr />
{{/Generated Sentence}}

<div class="media">
  {{#Generated Audio}}
    {{Generated Audio}}
  {{/Generated Audio}}
  {{^Generated Audio}}
    {{SentenceAudio}}
  {{/Generated Audio}}
</div>