-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
196 lines (178 loc) · 7.71 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Anki Assistant</title>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
color: #333;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
h1 {
color: #2c3e50;
}
h2 {
color: #34495e;
}
code {
background-color: #f4f4f4;
padding: 2px 4px;
border-radius: 4px;
}
pre {
background-color: #f4f4f4;
padding: 10px;
border-radius: 4px;
overflow-x: auto;
}
</style>
</head>
<body>
<h1>Anki Assistant</h1>
<p>Anki Assistant is a Node.js application that helps you create and update Anki decks for language learning. It allows you to input words or phrases in your native language, translates them to your target language, and adds them as cards to an Anki deck.</p>
<p>It uses Anthropic for fluent translations and Narakeet for audio generation.</p>
<img width="541" alt="Demo" src="https://github.com/user-attachments/assets/0156ba34-6bbb-4f2b-a4fb-f85b00c76734">
<img width="414" alt="Cards" src="https://github.com/user-attachments/assets/cc34f70f-4850-44eb-83cc-a9c7d26b06ac">
<h2>Installation</h2>
<ol>
<li>
<p>Clone this repository:</p>
<pre><code>git clone https://github.com/yourusername/anki-assistant.git
cd anki-assistant</code></pre>
</li>
<li>
<p>Install the required dependencies:</p>
<pre><code>npm i</code></pre>
</li>
<li>
<p>Set up the environment variables:</p>
<pre><code>npm run setup</code></pre>
</li>
<li>
<p>Open the <code>.env</code> file and update the following environment variables:</p>
<pre><code>ANTHROPIC_API_KEY=your_anthropic_api_key
NARAKEET_API_KEY=your_narakeet_api_key
NATIVE_LANGUAGE=your_native_language # The language you speak
TARGET_LANGUAGE=your_target_language # The language you want to learn
NATIVE_LANGUAGE_VOICE=your_native_language_voice # The voice to use for the native language audio
TARGET_LANGUAGE_VOICE=your_target_language_voice # The voice to use for the target language audio</code></pre>
<p>Replace the placeholder values with your actual API keys and preferences.</p>
<p>You will need API keys for both Anthropic and Narakeet.</p>
<ul>
<li>Link to Anthropic: <a href="https://console.anthropic.com/dashboard">https://console.anthropic.com/dashboard</a></li>
<li>Link to Narakeet: <a href="https://www.narakeet.com/">https://www.narakeet.com/</a></li>
<li>Link to Narakeet voices: <a href="https://www.narakeet.com/languages/">https://www.narakeet.com/languages/</a></li>
</ul>
</li>
</ol>
<h2>Usage</h2>
<h3>Interactive Mode</h3>
<ol>
<li>
<p>Run the application:</p>
<pre><code>npm start</code></pre>
</li>
<li>
<p>Follow the prompts in the console:</p>
<ul>
<li>Enter a word or phrase in your native language.</li>
<li>The application will provide a translation.</li>
<li>Confirm if the translation is correct (y/n).</li>
<li>Repeat this process for as many words as you want to add.</li>
<li>Enter 'q' when you're done adding words.</li>
</ul>
</li>
<li>
<p>The application will create an Anki deck file (<code>.apkg</code>) in the project directory.</p>
</li>
<li>
<p>Import the generated <code>.apkg</code> file into Anki to see your new cards.</p>
</li>
</ol>
<h3>Batch Mode</h3>
<p>In addition to the interactive mode, you can process multiple phrases at once using batch mode:</p>
<ol>
<li>
<p>Create a <code>phrases.txt</code> file in the project directory (you can copy from <code>phrases.txt.example</code>):</p>
<pre><code>cp phrases.txt.example phrases.txt</code></pre>
<p>Then edit <code>phrases.txt</code> with your phrases, one per line:</p>
<pre><code># Lines starting with # are ignored as comments
hello
goodbye
thank you
how are you</code></pre>
</li>
<li>
<p>Run the batch processor:</p>
<pre><code>npm run batch</code></pre>
</li>
<li>
<p>For each phrase, the application will:</p>
<ul>
<li>Show the translation</li>
<li>Ask for confirmation</li>
<li>Generate audio files</li>
<li>Add the card to your deck if confirmed</li>
</ul>
</li>
</ol>
<p>This is particularly useful when you have a list of phrases prepared in advance.</p>
<h3>Audio Tapes</h3>
<p>You can also create audio learning tapes that combine multiple phrases into a single MP3 file. Each phrase follows this pattern:</p>
<ol>
<li>Native language phrase</li>
<li>5-second pause</li>
<li>Target language phrase (normal speed)</li>
<li>3-second pause</li>
<li>Target language phrase (0.7x speed)</li>
<li>3-second pause</li>
<li>Target language phrase (0.85x speed)</li>
<li>3-second pause</li>
<li>Target language phrase (normal speed)</li>
<li>3-second pause before next phrase</li>
</ol>
<p>This format is particularly useful for listening and pronunciation practice, when you may not be able to read the text.</p>
<ol>
<li>
<p>Create an <code>audio-phrases.txt</code> file in the project directory (you can copy from <code>audio-phrases.txt.example</code>):</p>
<pre><code>cp audio-phrases.txt.example audio-phrases.txt</code></pre>
<p>Then edit <code>audio-phrases.txt</code> with your phrases. You can either:</p>
<ol>
<li>
<p>Add just the native language phrase:</p>
<pre><code>I usually eat breakfast at home
She can speak three languages very well
The cat likes to sleep under the table</code></pre>
</li>
<li>
<p>Or include both native phrase and translation, separated by <code>---</code>:</p>
<pre><code>I usually eat breakfast at home --- Es parasti ēdu brokastis mājās
She can speak three languages very well --- Viņa var ļoti labi runāt trīs valodās
The cat likes to sleep under the table --- Kaķim patīk gulēt zem galda</code></pre>
</li>
</ol>
<p>If you provide translations, they will be used directly. Otherwise, the application will generate translations automatically.</p>
</li>
<li>
<p>Run the audio tape creator:</p>
<pre><code>npm run audio</code></pre>
</li>
<li>
<p>The application will:</p>
<ul>
<li>Translate each phrase</li>
<li>Generate audio for both languages</li>
<li>Create slower versions for practice</li>
<li>Combine everything into a single MP3 file</li>
</ul>
</li>
</ol>
<p>The output will be saved as <code>[TARGET_LANGUAGE]_audio_tape.mp3</code> in your project directory.</p>
<p>For more information and the source code, visit the <a href="https://github.com/GeoFro/anki-assistant">GitHub repository</a>.</p>
</body>
</html>