Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
39459a0f6e | |||
cccf7189e3 | |||
2c51f2cea3 | |||
2ad014fcd8 | |||
4ad289d02d | |||
28ccfdd227 | |||
f83d5c934d | |||
4f9eb3b7d1 | |||
c44a38f3c8 | |||
f760e7f0fa |
2
.playsound.py
Normal file
2
.playsound.py
Normal file
@@ -0,0 +1,2 @@
|
||||
def playsound(p):
|
||||
print(p)
|
@@ -1,9 +1,9 @@
|
||||
# 潜进 (HeurAMS) - 实验型辅助记忆程序
|
||||
# 潜进 (HeurAMS) - 启发式辅助记忆程序
|
||||
> 形人而我无形,**则我专而敌分**
|
||||
|
||||
## 概述
|
||||
|
||||
"潜进" (HeurAMS, 中文含义: 启发式辅助记忆软件) 是为习题册, 古诗词, 及其他问答/记忆/理解型知识设计的辅助记忆软件, 提供动态规划的优化记忆方案
|
||||
"潜进" (HeurAMS) 是为习题册, 古诗词, 及其他问答/记忆/理解型知识设计的辅助记忆软件, 提供动态规划的优化记忆方案
|
||||
|
||||
## 技术集成与特性
|
||||
|
||||
|
14
auxiliary.py
14
auxiliary.py
@@ -2,6 +2,9 @@ import time
|
||||
import pathlib
|
||||
import toml
|
||||
import typing
|
||||
import playsound
|
||||
import threading
|
||||
import edge_tts as tts
|
||||
|
||||
class ConfigFile:
|
||||
def __init__(self, path: str):
|
||||
@@ -34,6 +37,17 @@ class ConfigFile:
|
||||
"""获取配置值,如果不存在返回默认值"""
|
||||
return self.data.get(key, default)
|
||||
|
||||
def action_play_voice(content):
|
||||
def play():
|
||||
communicate = tts.Communicate(
|
||||
content,
|
||||
"zh-CN-YunjianNeural",
|
||||
)
|
||||
communicate.save_sync(
|
||||
f"./cache/voice/{content}"
|
||||
)
|
||||
playsound()
|
||||
threading.Thread(target=play).start()
|
||||
|
||||
def get_daystamp() -> int:
|
||||
"""获取当前日戳(以天为单位的整数时间戳)"""
|
||||
|
@@ -188,6 +188,7 @@ class FillBlank(Composition):
|
||||
yield Button("退格", id=self.regid(f"delete"))
|
||||
|
||||
def handler(self, event, type_):
|
||||
# TODO: 改动:在线错误纠正
|
||||
if type_ == "button":
|
||||
if self.recid(event.button.id) == "delete":
|
||||
if len(self.inputlist) > 0:
|
||||
@@ -279,7 +280,7 @@ class TestScreen(Screen):
|
||||
|
||||
|
||||
class AppLauncher(App):
|
||||
CSS_PATH = "styles.tcss"
|
||||
CSS_PATH = "styles.css"
|
||||
TITLE = "测试布局"
|
||||
BINDINGS = [("escape", "quit", "退出"), ("d", "toggle_dark", "改变色调")]
|
||||
SCREENS = {
|
||||
|
19
main.py
19
main.py
@@ -22,18 +22,7 @@ import auxiliary as aux
|
||||
import compositions as compo
|
||||
import builtins
|
||||
|
||||
# Hook python 的 open() 函数, 使用 utf-8 (兼容 Windows 万年 GBK)
|
||||
|
||||
_original_open = builtins.open
|
||||
|
||||
def _open(*args, **kwargs):
|
||||
if "encoding" not in kwargs:
|
||||
kwargs["encoding"] = "utf-8"
|
||||
return _original_open(*args, **kwargs)
|
||||
|
||||
builtins.open = _open
|
||||
|
||||
ver = "0.3.0"
|
||||
ver = "0.3.1"
|
||||
|
||||
config = aux.ConfigFile("config.toml")
|
||||
|
||||
@@ -62,6 +51,8 @@ class MemScreen(Screen):
|
||||
self.compo = next(self.reactor.current_appar)
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
if type(self.compo).__name__ == "Recognition":
|
||||
self.action_play_voice()
|
||||
yield Header(show_clock=True)
|
||||
with Center():
|
||||
yield Static(
|
||||
@@ -116,8 +107,10 @@ class MemScreen(Screen):
|
||||
|
||||
def refresh_ui(self):
|
||||
self.call_later(self.recompose)
|
||||
print(type(self.compo).__name__)
|
||||
|
||||
def action_play_voice(self):
|
||||
print("VOICE")
|
||||
def play():
|
||||
cache_dir = pathlib.Path(f"./cache/voice/")
|
||||
cache_dir.mkdir(parents=True, exist_ok=True)
|
||||
@@ -250,7 +243,7 @@ class FileSelectorScreen(Screen):
|
||||
|
||||
|
||||
class AppLauncher(App):
|
||||
CSS_PATH = "styles.tcss"
|
||||
CSS_PATH = "styles.css"
|
||||
TITLE = "潜进 - 辅助记忆程序"
|
||||
BINDINGS = [("escape", "quit", "退出"), ("d", "toggle_dark", "改变色调")]
|
||||
SCREENS = {
|
||||
|
0
nucleon_todo/书愤.toml
Normal file
0
nucleon_todo/书愤.toml
Normal file
0
nucleon_todo/五代史伶官传序.toml
Normal file
0
nucleon_todo/五代史伶官传序.toml
Normal file
0
nucleon_todo/六国论.toml
Normal file
0
nucleon_todo/六国论.toml
Normal file
0
nucleon_todo/劝学.toml
Normal file
0
nucleon_todo/劝学.toml
Normal file
0
nucleon_todo/声声慢.toml
Normal file
0
nucleon_todo/声声慢.toml
Normal file
0
nucleon_todo/子路曾皙冉有公西华侍坐.toml
Normal file
0
nucleon_todo/子路曾皙冉有公西华侍坐.toml
Normal file
0
nucleon_todo/客至.toml
Normal file
0
nucleon_todo/客至.toml
Normal file
0
nucleon_todo/将进酒.toml
Normal file
0
nucleon_todo/将进酒.toml
Normal file
0
nucleon_todo/屈原列传.toml
Normal file
0
nucleon_todo/屈原列传.toml
Normal file
0
nucleon_todo/山居秋暝.toml
Normal file
0
nucleon_todo/山居秋暝.toml
Normal file
0
nucleon_todo/师说.toml
Normal file
0
nucleon_todo/师说.toml
Normal file
0
nucleon_todo/归去来兮辞.toml
Normal file
0
nucleon_todo/归去来兮辞.toml
Normal file
0
nucleon_todo/归田园居.toml
Normal file
0
nucleon_todo/归田园居.toml
Normal file
0
nucleon_todo/念奴娇赤壁怀古.toml
Normal file
0
nucleon_todo/念奴娇赤壁怀古.toml
Normal file
0
nucleon_todo/念奴娇过洞庭.toml
Normal file
0
nucleon_todo/念奴娇过洞庭.toml
Normal file
0
nucleon_todo/扬州慢.toml
Normal file
0
nucleon_todo/扬州慢.toml
Normal file
0
nucleon_todo/报任安书.toml
Normal file
0
nucleon_todo/报任安书.toml
Normal file
0
nucleon_todo/拟行路难.toml
Normal file
0
nucleon_todo/拟行路难.toml
Normal file
0
nucleon_todo/无衣.toml
Normal file
0
nucleon_todo/无衣.toml
Normal file
0
nucleon_todo/春江花月夜.toml
Normal file
0
nucleon_todo/春江花月夜.toml
Normal file
0
nucleon_todo/望海潮.toml
Normal file
0
nucleon_todo/望海潮.toml
Normal file
0
nucleon_todo/朝天子.toml
Normal file
0
nucleon_todo/朝天子.toml
Normal file
0
nucleon_todo/李凭箜篌引.toml
Normal file
0
nucleon_todo/李凭箜篌引.toml
Normal file
0
nucleon_todo/桂枝香.toml
Normal file
0
nucleon_todo/桂枝香.toml
Normal file
0
nucleon_todo/梦游天姥吟留别.toml
Normal file
0
nucleon_todo/梦游天姥吟留别.toml
Normal file
0
nucleon_todo/永遇乐.toml
Normal file
0
nucleon_todo/永遇乐.toml
Normal file
0
nucleon_todo/江城子.toml
Normal file
0
nucleon_todo/江城子.toml
Normal file
0
nucleon_todo/涉江采芙蓉.toml
Normal file
0
nucleon_todo/涉江采芙蓉.toml
Normal file
0
nucleon_todo/燕歌行.toml
Normal file
0
nucleon_todo/燕歌行.toml
Normal file
0
nucleon_todo/琵琶行.toml
Normal file
0
nucleon_todo/琵琶行.toml
Normal file
0
nucleon_todo/登岳阳楼.toml
Normal file
0
nucleon_todo/登岳阳楼.toml
Normal file
0
nucleon_todo/登快阁.toml
Normal file
0
nucleon_todo/登快阁.toml
Normal file
0
nucleon_todo/登泰山记.toml
Normal file
0
nucleon_todo/登泰山记.toml
Normal file
0
nucleon_todo/登高.toml
Normal file
0
nucleon_todo/登高.toml
Normal file
0
nucleon_todo/短歌行.toml
Normal file
0
nucleon_todo/短歌行.toml
Normal file
0
nucleon_todo/石钟山记.toml
Normal file
0
nucleon_todo/石钟山记.toml
Normal file
0
nucleon_todo/礼运.toml
Normal file
0
nucleon_todo/礼运.toml
Normal file
0
nucleon_todo/离骚.toml
Normal file
0
nucleon_todo/离骚.toml
Normal file
0
nucleon_todo/种树郭橐驼传.toml
Normal file
0
nucleon_todo/种树郭橐驼传.toml
Normal file
0
nucleon_todo/答司马谏议书.toml
Normal file
0
nucleon_todo/答司马谏议书.toml
Normal file
0
nucleon_todo/苏幕遮.toml
Normal file
0
nucleon_todo/苏幕遮.toml
Normal file
0
nucleon_todo/菩萨蛮.toml
Normal file
0
nucleon_todo/菩萨蛮.toml
Normal file
0
nucleon_todo/虞美人.toml
Normal file
0
nucleon_todo/虞美人.toml
Normal file
0
nucleon_todo/蜀相.toml
Normal file
0
nucleon_todo/蜀相.toml
Normal file
0
nucleon_todo/蜀道难.toml
Normal file
0
nucleon_todo/蜀道难.toml
Normal file
0
nucleon_todo/论语.toml
Normal file
0
nucleon_todo/论语.toml
Normal file
0
nucleon_todo/谏太宗十思疏.toml
Normal file
0
nucleon_todo/谏太宗十思疏.toml
Normal file
0
nucleon_todo/贺新郎.toml
Normal file
0
nucleon_todo/贺新郎.toml
Normal file
0
nucleon_todo/赤壁赋.toml
Normal file
0
nucleon_todo/赤壁赋.toml
Normal file
0
nucleon_todo/过秦论.toml
Normal file
0
nucleon_todo/过秦论.toml
Normal file
0
nucleon_todo/锦瑟.toml
Normal file
0
nucleon_todo/锦瑟.toml
Normal file
0
nucleon_todo/长亭送别.toml
Normal file
0
nucleon_todo/长亭送别.toml
Normal file
0
nucleon_todo/阿房宫赋.toml
Normal file
0
nucleon_todo/阿房宫赋.toml
Normal file
0
nucleon_todo/青玉案.toml
Normal file
0
nucleon_todo/青玉案.toml
Normal file
0
nucleon_todo/静女.toml
Normal file
0
nucleon_todo/静女.toml
Normal file
0
nucleon_todo/项脊轩志.toml
Normal file
0
nucleon_todo/项脊轩志.toml
Normal file
0
nucleon_todo/鹊桥仙.toml
Normal file
0
nucleon_todo/鹊桥仙.toml
Normal file
@@ -21,8 +21,8 @@ def proc_file(path: Path):
|
||||
c = 0
|
||||
for i in nu.nucleons:
|
||||
c += 1
|
||||
print(f"预缓存 [{nu.name}] ({c}/{len(nu)}): {i['content']}")
|
||||
precache(i['content'])
|
||||
print(f"预缓存 [{nu.name}] ({c}/{len(nu)}): {i['content'].replace('/', '')}")
|
||||
precache(i['content'].replace('/', ''))
|
||||
|
||||
|
||||
def walk(path_str: str):
|
17
webshare/static/js/script.js
Normal file
17
webshare/static/js/script.js
Normal file
@@ -0,0 +1,17 @@
|
||||
function getStartUrl() {
|
||||
const url = new URL(window.location.href);
|
||||
const params = new URLSearchParams(url.search);
|
||||
params.delete("delay");
|
||||
return url.pathname + "?" + params.toString();
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
const ping_url = document.body.dataset.pingurl;
|
||||
if (ping_url) {
|
||||
await fetch(ping_url, {
|
||||
method: "GET",
|
||||
mode: "no-cors",
|
||||
});
|
||||
}
|
||||
window.location.href = getStartUrl();
|
||||
}
|
@@ -4,6 +4,7 @@
|
||||
<link rel="stylesheet" href="{{ config.static.url }}css/xterm.css" />
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto%20Mono"/>
|
||||
<script src="{{ config.static.url }}js/textual.js"></script>
|
||||
<script src="{{ config.static.url }}js/script.js"></script>
|
||||
<style>
|
||||
body {
|
||||
background: #000000;
|
||||
@@ -99,24 +100,6 @@
|
||||
z-index: 5;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function getStartUrl() {
|
||||
const url = new URL(window.location.href);
|
||||
const params = new URLSearchParams(url.search);
|
||||
params.delete("delay");
|
||||
return url.pathname + "?" + params.toString();
|
||||
}
|
||||
async function refresh() {
|
||||
const ping_url = document.body.dataset.pingurl;
|
||||
if (ping_url) {
|
||||
await fetch(ping_url, {
|
||||
method: "GET",
|
||||
mode: "no-cors",
|
||||
});
|
||||
}
|
||||
window.location.href = getStartUrl();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body data-pingurl="{{ ping_url }}">
|
||||
<div class="dialog-container intro-dialog">
|
||||
|
Reference in New Issue
Block a user