首页 > 其他分享 >Edu-Dict + English Learning Materials: Mdict

Edu-Dict + English Learning Materials: Mdict

时间:2024-02-15 11:44:41浏览次数:17  
标签:spx Dictionary Materials Dict mp3 file Edu wav 词典

https://mdict.org
https://github.com/xiaolai/apple-computer-literacy/blob/main/Install-Mdict-Dictionaries-to-macOS-Dictionary.md

https://downloads-direct.freemdict.com/Language_Learning_Videos/英语/
https://downloads.freemdict.com
https://mdx.mdict.org

Mdict词库:免费下载mdx/mdd/css文件资源,支持欧路,深蓝,goldendict电子词典
Mdict 词典转换

  1. Mdict 格式词典下载

freemdict.com 和 mdict.org上有很多 Mdict 格式的词典文件。Mdict 的词典文件,通常由一个 .mdx 文件和一个 .mdd 文件构成,声音和图片都打包在 .mdd 文件之中。需要同时下载两个文件,放到同一个目录中进行处理。

推荐

Cambridge Advanced Learner's Dictionary 4ed
Merriam-Webster's Collegiate Dictionary 11ed (Pic&Sound)
Longman Dictionary of Contemporary English 6ed
Longman Language Activator
Collins CoBuild Advanced Learner's Dictionary
American Heritage Dictionary 5ed
Oxford Collocation Dictionary
事实上,前两个就已经足够了(都是有声词典)……

  1. 所需工具与环境

Python (python 3.11.5 specified)

conda create -n mdict python=3.11.5
conda activate mdict
pip install pyglossary lxml beautifulsoup4 html5lib

install Homebrew; if brew already installed, skip this section.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

speex for converting spx to wav

brew install speex

ffmpeg for converting wav to mp3

brew install ffmpeg
另外,还需要下载 Dictionary Development Kit

下载地址:Additional Tools for Xcode

下载与操作系统中安装的 xcode 匹配的 “Additional Tools for Xcode”

check out xcode version

xcodebuild -version
将其中 Utilities 下的 Dictionary Development Kit 目录整体拷贝粘贴到本机 /Applications/Utilities 下

用以下代码替换 /Applications/Utilities/Dictionary Development Kit/bin/build_dict.sh 的第 221 行:

rsync -a "$OTHER_RSRC_DIR"/ "$OBJECTS_DIR"/dict.dictionary/"$CONTENTS_DATA_PATH" || error "Error."
3. 转换 mdx

pyglossary 使用方法如下:

pyglossary --write-format=AppleDict <mdx_file> <output_dir>
以 Merriam-Webster's_Collegiate_Dictionary_11th(Pic&Sound).mdx 为例:

pyglossary --write-format=AppleDict Merriam-Webster's_Collegiate_Dictionary_11th(Pic&Sound).mdx "Merriam-Webster's Collegiate Dictionary"
4. spx 文件的转换

如果 OtherResources 目录里的声音文件原本就是 .mp3 就可以跳过这一步。但,如果是 .spx 的话,就需要将 .spx 文件转换为 .mp3 文件:

long time needed, possibly up to an hour or more...

for file in *.spx; do
# Decode the SPX to WAV
speexdec "$file" "${file%.spx}.wav"
# Encode the WAV to MP3
ffmpeg -i "${file%.spx}.wav" -f mp3 "${file%.spx}.mp3"
# Optionally remove the intermediate SPX file
rm "$file"
# Optionally remove the intermediate WAV file
rm "${file%.spx}.wav"
done
而后,xml 文件里的声音文件名也需要转换(可以提前用 vscode 或者 sublime text 打开 xml 查看一下,根据需要批量替换的字符串修改以下命令)

sed -i '' 's/.spx/.mp3/g' file.xml
如果需要将 .wav 文件批量转换为 .mp3:

for file in *.wav; do
ffmpeg -i "$file" -f mp3 "${file%.wav}.mp3"
# Optionally remove the intermediate WAV file
rm "$file"
done
5. 其它定制信息

pyglossary 生成的文件中,.css 文件,可根据自己需要修改。

macOS 原生词典里面是不支持 base64 格式的字体文件的,所以我们需要手动将原先css里面base64格式的字体转换成它原来的样子并放到 Contents 文件夹下。

Base64 Online - base64 decode and encode (motobit.com)

.plist 文件中,CFBundleName 是词典缩写(显示在词典的标签栏上),CFBundleDisplayName 是词典名称的完整名称(显示在 Preference 对话框中),可根据自己需要修改。

  1. 安装词典

cd "Merriam-Webster's Collegiate Dictionary"
make
生成的词典在 objects 目录中。

安装词典到 ~/Library/Dictionaries:

make install
而后就可以在 Dictionary 里,cmd+, 在对话框里选择新安装的词典了。

  1. 删除词典

在 ~/Library/Dictionaries 目录中将词典的整个目录删掉即可。

  1. 捷径

可以在百度网盘下载一个压缩包,解压缩后,把其中六个词典目录挪到 ~/Library/Dictionaries 目录之下即可,重新启动 Dictionary.app,cmd+, 在对话框里选择新安装的词典。

链接: https://pan.baidu.com/s/1TpYyYYdvFGsMLI65i7NBog?pwd=buqn 提取码: buqn

Cambridge Advanced Learner's Dictionary.dictionary
Collins COBUILD Advanced Learner's Dictionary.dictionary
Merriam-Webster's Collegiate Dictionary.dictionary
Longman Dictionary of Contemporary English 6ed.dictionary
Longman Language Activator.dictionary
Oxford Collocation Dictionary.dictionary

标签:spx,Dictionary,Materials,Dict,mp3,file,Edu,wav,词典
From: https://www.cnblogs.com/abaelhe/p/18016103

相关文章

  • C. Physical Education Lesson
    原题链接题解再结合代码应该就能看得懂了吧。。。至于赛时怎么想出来的。我是观察样例得出来的时间复杂度\(O(2·t·\sqrt{n})\)code#include<bits/stdc++.h>#definelllonglongusingnamespacestd;inlinevoidread(ll&x){x=0;llflag=1;cha......
  • CF1928C Physical Education Lesson
    原题链接先考虑暴力枚举每个\(k\)是否合法,发现\(k\)合法当且仅当\((2k-2)\mid(n-x)\)或者\((2k-2)\mid(n+x-2)\)并且\(k\geqx\)。因为当\(n\)处于每一段中的第\(1\simk\)个数中时\(n-x\)是上一段的结尾,\(n\)处于每一段中的第\(k\sim2k-2\)个数中时\(n+(x......
  • Atcoder Educational DP Contest 题解
    比赛链接:Atcoderr或者题单A:Frog1常规线性dp,注意到对于每个落点来说,青蛙只能由第\(i-1\)个石头或者第\(i-2\)个石头转移得到,那么我们让\(dp[i]\)为当跳到第\(i\)个石头上的最小费用。此时显然有:\[dp_i=\min(dp_{i-1}+\left|h_i-h_{i-1}\right|,dp_{i-2}+\left|h_......
  • .NET(C#)遍历(for,foreach,while)字典(Dictionary)的几种方法
    ​ .NET(C#)中,Dictionary<TKey,TValue>是一种非常实用的集合类型,用于存储键值对的集合。遍历Dictionary的方法有多种,包括使用for循环、foreach循环和while循环。使用foreach循环是遍历Dictionary中所有键值对最常见和最简单的方法。for和while循环在遍历Dic......
  • 在k8S中,Scheduler作用及实现原理是什么?
    在Kubernetes(k8s)中,Scheduler是一个核心组件,它的主要作用是负责集群中的Pod调度。具体来说:Scheduler的作用:资源分配:根据每个Pod的资源请求(如CPU、内存),以及节点当前的可用资源情况,选择合适的Node来运行Pod。满足约束条件:考虑Pod的调度约束条件和亲和性/反亲和性规则,例如节点标签......
  • 在k8S中,Scheduler使用哪两种算法将Pod绑定到worker节点?
    在Kubernetes(k8S)中,Scheduler使用两种主要的算法阶段来决定将Pod绑定到哪个worker节点上:预选算法(Predicates)预选阶段的主要目标是过滤掉不满足调度条件的节点。Scheduler会根据一系列预定义的预选策略对所有可用节点进行筛选。这些策略可能包括但不限于:检查节点上的资源是否......
  • Educational Codeforces Round 135 (Rated for Div. 2)C. Digital Logarithm(思维)
    目录题目链接题意题解代码题目链接C.DigitalLogarithm题意给两个长度位\(n\)的数组\(a\)、\(b\),一个操作\(f\)定义操作\(f\)为,\(a[i]=f(a[i])=a[i]\)的位数求最少多少次操作可以使\(a、b\)两个数组变得完全相同题解性质:对于任何数,经过两次操作我们一定可以让其变为\(......
  • 使用FluentScheduler和IIS预加载在asp.net中实现定时任务管理
    FluentScheduler介绍github地址:https://github.com/fluentscheduler/FluentSchedulerFluentScheduler是一个简单的任务调度框架,使用起来非常方便,这个框架也是我在搜索iis预加载的时候偶然间发现的,立马拿来试用一下,感觉爽呆了,当然还有Quarz.Net之类的其他任务管理框架,不过看配置......
  • Educational Codeforces Round 145 (Rated for Div. 2)C. Sum on Subarrays(构造)
    很意思的一道构造题题意:给一个\(n、k\),让构造长度为n的数组满足,子数组为整数的个数为k个,负数的为\(k-(n+1)*n/2\),每个数的范围为\([-1000,1000]\)这种构造题可以考虑就是前一段可以一直用一样的、最小的。我们观察可以发现\(k+k-(n+1)*n/2=(n+1)*n/2\)也就是所有子数组......
  • C#的DataTable、List、Dictionary、JSON、XML之间的转换
    1.DataTable转List//创建一个DataTable对象DataTabledataTable=newDataTable();//将DataTable转换为List<DataRow>List<DataRow>dataList=dataTable.AsEnumerable().ToList(); 2、DataTable转Dictionary//创建一个DataTable对象DataTabledataTable=new......