Skip to content

Commit 5729c31

Browse files
committed
fix: update player
1 parent ea839d1 commit 5729c31

File tree

3 files changed

+43
-46
lines changed

3 files changed

+43
-46
lines changed

lingoanki/diary.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,8 @@ def openai_translate_sentence(self, sentence_dict):
774774
- **DO NOT invent extra words or modify the original meaning of the sentence.**
775775
- If the primary_language_sentence is not grammatically correct, or if there are minor issues, you could fix the grammar and ponctuation only.
776776
- if the primary_language_sentence has reference about I, as me, you should know that my gender is {self.config["gender"]} as this will be useful to have the proper grammar and ending on words
777+
- Generate a sentence that is ready to be spoken by a Text-to-Speech system. Expand abbreviations that are not normally spoken as-is (e.g., 'km/h' should become 'kilometers per hour'), but keep common spoken abbreviations (e.g., 'AM', 'PM') unchanged. Ensure the result is natural for TTS. Adapt abbreviation expansion appropriately to the target language {self.config["languages"]["study_language"]}.
778+
- In addition, when generating text for non-English languages, expand non-spoken abbreviations according to natural usage in that language (e.g., in French, 'km/h' ➔ 'kilomètres par heure').
777779
778780
Example output format:
779781
@@ -1315,6 +1317,8 @@ def openai_tprs(self, study_language_sentence):
13151317
- **Try to match the emotional tone or style of the sentence (e.g., casual, funny, dramatic).**
13161318
- **Avoid repeating the same phrasing or vocabulary in both the questions and answers. Use different angles, emotions, or contextual clues to make each question unique.**
13171319
- **You can explore the setting, emotional dynamics, or deeper meanings behind the actions in the sentence.**
1320+
- Generate a sentence that is ready to be spoken by a Text-to-Speech system. Expand abbreviations that are not normally spoken as-is (e.g., 'km/h' should become 'kilometers per hour'), but keep common spoken abbreviations (e.g., 'AM', 'PM') unchanged. Ensure the result is natural for TTS. Adapt abbreviation expansion appropriately to the target language {self.config["languages"]["study_language"]}.
1321+
- In addition, when generating text for non-English languages, expand non-spoken abbreviations according to natural usage in that language (e.g., in French, 'km/h' ➔ 'kilomètres par heure').
13181322
13191323
### Example 1 – Neutral:
13201324
Input sentence: "Fredag var Johanne veldig syk. Vi ble hjemme og dro for å fiske med Emil og Mati. Jeg var den første som fanget noe – min første norske fisk."

lingoanki/templates/diary.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!doctype html>
22
<html>
33
<head>
4-
<meta name="viewport" content="width=device-width, initial-scale=1">
4+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
55
<link rel="icon" href="{{ url_for('static', filename='icon.ico') }}" type="image/x-icon">
66

77

lingoanki/templates/diary_tprs_play_audio.html

Lines changed: 38 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,44 @@
33
content %}
44

55
<style>
6+
.audio-player-container {
7+
width: 100%;
8+
display: flex;
9+
justify-content: center;
10+
position: fixed;
11+
bottom: 0;
12+
left: 0;
13+
right: 0;
14+
background: white; /* background on container */
15+
box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2);
16+
padding: 0.5rem 0;
17+
z-index: 1000; /* ensure it’s above everything else */
18+
}
19+
620
.audio-player {
7-
position: sticky;
8-
top: 0;
9-
background: white;
10-
z-index: 1000;
11-
padding: 1rem;
21+
width: 100%;
22+
max-width: 600px;
1223
display: flex;
1324
flex-direction: column;
1425
align-items: center;
15-
gap: 1rem;
16-
max-width: 400px;
17-
margin: auto;
18-
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
19-
transition: all 0.3s ease;
20-
}
21-
22-
/* On small screens, override to fixed */
23-
@media (max-width: 768px) {
24-
.audio-player {
25-
position: fixed;
26-
top: 0;
27-
left: 0;
28-
right: 0;
29-
width: 100%;
30-
max-width: none;
31-
padding: 0.5rem;
32-
background: white;
33-
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
34-
}
26+
gap: 0.5rem;
3527
}
3628
</style>
3729

3830

3931
<h2>{{ _('select an mp3 file to play') }}</h2>
4032

41-
<form id="audioform">
42-
<label for="file_select">{{ _('choose an audio file') }}:</label>
43-
<select id="file_select" name="file">
33+
<form id="audioform" style="display: flex; flex-wrap: wrap; gap: 0.5rem; max-width: 100%;">
34+
<label for="file_select" style="flex: 1 1 100%;">{{ _('choose an audio file') }}:</label>
35+
<select id="file_select" name="file" style="flex: 1 1 250px; max-width: 100%;">
4436
{% for mp3_file in mp3_files %}
4537
<option value="{{ mp3_file }}">{{ mp3_file }}</option>
4638
{% endfor %}
4739
</select>
48-
<button type="submit">{{ _('choose file') }}</button>
40+
<button type="submit" style="flex: 0 0 auto;">{{ _('choose file') }}</button>
4941
</form>
5042

43+
5144
<script>
5245
document.getElementById("audioform").addEventListener("submit", function(event) {
5346
event.preventDefault();
@@ -59,28 +52,16 @@ <h2>{{ _('select an mp3 file to play') }}</h2>
5952
</script>
6053
<script>
6154
function playselectedfile() {
62-
const file = document.getelementbyid("file_select").value;
63-
window.location.href = "/view_markdown/" + encodeuricomponent(file);
55+
const file = document.getElementById("file_select").value;
56+
window.location.href = "/view_markdown/" + encodeURIComponent(file);
6457
}
6558
</script>
6659

6760
{% if filename %}
6861
<h3>{{ _('now playing') }}: {{ filename }}</h3>
6962

70-
<!-- Custom Audio Player -->
71-
<script>
72-
document.addEventListener('scroll', function() {
73-
const player = document.querySelector('.audio-player');
74-
if (window.scrollY > 50) { // when scrolled 50px down
75-
player.style.transform = 'scale(0.95)';
76-
player.style.opacity = '0.9';
77-
} else {
78-
player.style.transform = 'scale(1)';
79-
player.style.opacity = '1';
80-
}
81-
});
82-
</script>
8363

64+
<div class="audio-player-container">
8465
<div class="audio-player">
8566
<audio id="audio" preload="metadata">
8667
<source src="{{ url_for('play_audio', filename=filename) }}" type="audio/mp3">
@@ -100,6 +81,7 @@ <h3>{{ _('now playing') }}: {{ filename }}</h3>
10081
<!-- Play / Pause -->
10182
<button onclick="togglePlay()" id="playpause" style="font-size: 1.5rem;">▶️</button>
10283
</div>
84+
</div>
10385

10486

10587
<script>
@@ -207,4 +189,15 @@ <h3>{{ _('markdown content') }}:</h3>
207189
<div>{{ content|safe }}</div>
208190
{% else %}
209191
<p>no markdown content available for this file.</p>
210-
{% endif %} {% endif %} {% endblock %}
192+
{% endif %} {% endif %}
193+
194+
<!-- Add plyer at the bottom-->
195+
<style>
196+
.page-bottom-spacer {
197+
height: 180px; /* or whatever matches your player height */
198+
}
199+
</style>
200+
201+
202+
<div class="page-bottom-spacer"></div>
203+
{% endblock %}

0 commit comments

Comments
 (0)