diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml index 105ce2d..dd4c951 100644 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -1,5 +1,6 @@ + diff --git a/.idea/misc.xml b/.idea/misc.xml index fc4a7cb..db94cef 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,8 @@ - + + + \ No newline at end of file diff --git a/.idea/saveactions_settings.xml b/.idea/saveactions_settings.xml new file mode 100644 index 0000000..e3f405d --- /dev/null +++ b/.idea/saveactions_settings.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file diff --git a/CardUtils.py b/CardUtils.py index 1b2d6e0..ede99d0 100644 --- a/CardUtils.py +++ b/CardUtils.py @@ -7,7 +7,6 @@ @dataclass class CardUtils: - pimsleur_intervals: list[float] = field(default_factory=list) sm2_intervals: list[float] = field(default_factory=list) sm2_intervals_days: list[int] = field(default_factory=list) @@ -36,13 +35,13 @@ def __post_init__(self): def next_pimsleur_interval(self, correct_in_a_row: int) -> float: if correct_in_a_row < 0: correct_in_a_row = 0 - if correct_in_a_row > len(self.pimsleur_intervals) - 1 : + if correct_in_a_row > len(self.pimsleur_intervals) - 1: correct_in_a_row = len(self.pimsleur_intervals) - 1 return self.pimsleur_intervals[correct_in_a_row] def next_session_interval_secs(self, box: int) -> float: if box >= len(self.sm2_intervals): - box = len(self.sm2_intervals) -1 + box = len(self.sm2_intervals) - 1 if box < 0: box = 0 return self.sm2_intervals[box] diff --git a/ced_for_tts.py b/ced_for_tts.py index 7b1202b..a3fd758 100755 --- a/ced_for_tts.py +++ b/ced_for_tts.py @@ -15,7 +15,6 @@ def main() -> None: - os.chdir(os.path.dirname(__file__)) voices: list[str] = ["en-345-m", "en-360-m", "en-333-f", "en-361-f"] diff --git a/cherokee-vocab-data b/cherokee-vocab-data index 25aa7fc..3367044 160000 --- a/cherokee-vocab-data +++ b/cherokee-vocab-data @@ -1 +1 @@ -Subproject commit 25aa7fc2c47ce0b70a7ff482560ca175d500f88a +Subproject commit 336704466e7b17041da85af28a53e609ecc83e50 diff --git a/config.py b/config.py index 4bcbb4d..7c56f7d 100755 --- a/config.py +++ b/config.py @@ -12,7 +12,7 @@ class Config: deck_source: Optional[str] = None # Source a different dataset file for the vocabulary to process. review_deck: pathlib.Path | None = None - session_max_duration: float = 60 * 60 - 30 # Max 1 hour - 30 seconds per session. + session_max_duration: float = 25 * 60 - 30 # Max 1 hour - 30 seconds per session. create_mp4: bool = True break_on_end_note: bool = True diff --git a/configs/animals-cfg.json b/configs/animals-cfg.json index 5219bd9..3d08728 100644 --- a/configs/animals-cfg.json +++ b/configs/animals-cfg.json @@ -20,7 +20,7 @@ "review_cards_increment": 3, "review_cards_max_per_session": 42, "review_cards_per_session": 14, - "session_max_duration": 1785, + "session_max_duration": 1470, "sessions_to_create": 999, "sort_deck_by_size": false, "temp_dir": "tmp" diff --git a/configs/beginning-cherokee-cfg.json b/configs/beginning-cherokee-cfg.json index 6f15f0f..4a7c4ff 100644 --- a/configs/beginning-cherokee-cfg.json +++ b/configs/beginning-cherokee-cfg.json @@ -19,7 +19,7 @@ "review_cards_increment": 2, "review_cards_max_per_session": 21, "review_cards_per_session": 14, - "session_max_duration": 3570, + "session_max_duration": 1470, "sessions_to_create": 999, "sort_deck_by_size": false, "temp_dir": "tmp" diff --git a/configs/ced-sentences-cfg.json b/configs/ced-sentences-cfg.json index e8eb96f..5eb0314 100644 --- a/configs/ced-sentences-cfg.json +++ b/configs/ced-sentences-cfg.json @@ -19,7 +19,7 @@ "review_cards_increment": 2, "review_cards_max_per_session": 21, "review_cards_per_session": 12, - "session_max_duration": 3570, + "session_max_duration": 1470, "sessions_to_create": 999, "sort_deck_by_size": false, "temp_dir": "tmp" diff --git a/configs/cll1-v3-cfg.json b/configs/cll1-v3-cfg.json index 86d8ce6..eeb68f6 100644 --- a/configs/cll1-v3-cfg.json +++ b/configs/cll1-v3-cfg.json @@ -20,7 +20,7 @@ "review_cards_increment": 2, "review_cards_max_per_session": 42, "review_cards_per_session": 14, - "session_max_duration": 3570, + "session_max_duration": 1470, "sessions_to_create": 999, "sort_deck_by_size": false, "temp_dir": "tmp" diff --git a/configs/cll2-cfg.json b/configs/cll2-cfg.json index 5371126..af2622b 100644 --- a/configs/cll2-cfg.json +++ b/configs/cll2-cfg.json @@ -20,7 +20,7 @@ "review_cards_max_per_session": 21, "review_cards_per_session": 21, "review_deck": "review-decks/cll1-v3.json", - "session_max_duration": 3570, + "session_max_duration": 1470, "sessions_to_create": 999, "sort_deck_by_size": false, "temp_dir": "tmp" diff --git a/configs/osiyo-tohiju-then-what-cfg.json b/configs/osiyo-tohiju-then-what-cfg.json index cf37deb..553c30b 100644 --- a/configs/osiyo-tohiju-then-what-cfg.json +++ b/configs/osiyo-tohiju-then-what-cfg.json @@ -18,7 +18,7 @@ "review_cards_increment": 3, "review_cards_max_per_session": 42, "review_cards_per_session": 14, - "session_max_duration": 3570, + "session_max_duration": 1470, "sessions_to_create": 999, "sort_deck_by_size": false, "temp_dir": "tmp" diff --git a/main.py b/main.py index e9545e1..5425f15 100755 --- a/main.py +++ b/main.py @@ -250,8 +250,9 @@ def load_main_deck(source_file: str) -> LeitnerAudioDeck: if english_text: english_text += " Or. " english_text += text - if "v.t." in english_text or "v.i." in english_text: - english_text = english_text.replace("v.t.", "").replace("v.i.", "") + if "v. t." in english_text or "v.t." in english_text or "v. i." in english_text or "v.i." in english_text: + english_text = english_text.replace("v.t.", "").replace("v.i.", "")\ + .replace("v. t.", "").replace("v. i.", "") if "1." in english_text: english_text = english_text.replace("1.", "") english_text = english_text.replace("2.", ". Or, ") diff --git a/tts.py b/tts.py index 4b7a503..6ed6fc5 100644 --- a/tts.py +++ b/tts.py @@ -1,18 +1,17 @@ from __future__ import annotations import dataclasses -import pathlib -import shutil -import sys -import tempfile - -import boto3 import hashlib import os +import pathlib import re +import shutil import subprocess +import tempfile import textwrap import unicodedata + +import boto3 from boto3_type_annotations.polly import Client as Polly from pydub import AudioSegment from pydub import effects @@ -118,12 +117,14 @@ def tts_en(voice: str, text_en: str): if os.path.exists(mp3_en): return polly_client: Polly = boto3.Session().client("polly") - response = polly_client.synthesize_speech(OutputFormat="mp3", # - Text=text_en, # - VoiceId=voice, # - SampleRate=AMZ_HZ, # - LanguageCode="en-US", # - Engine="neural") + response = polly_client.synthesize_speech( + OutputFormat="mp3", # + Text=text_en, # + VoiceId=voice, # + SampleRate=AMZ_HZ, # + LanguageCode="en-US", # + Engine="neural" + ) with open(mp3_en + ".tmp", "wb") as w: w.write(response["AudioStream"].read()) shutil.move(mp3_en + ".tmp", mp3_en)