8.appendix added.

This commit is contained in:
xiaolai
2024-08-25 12:23:34 +08:00
parent e5bfa87753
commit b78bab86b0
33 changed files with 1057 additions and 720 deletions

View File

@@ -1,714 +0,0 @@
import { defineConfig } from "vitepress";
import { withMermaid } from "vitepress-plugin-mermaid";
import footnote from "markdown-it-footnote";
import sup from "markdown-it-sup";
import sub from "markdown-it-sub";
import mark from "markdown-it-mark";
import ins from "markdown-it-ins";
// import markdownit from 'markdown-it'
export default withMermaid(
// https://vitepress.dev/reference/site-config
defineConfig({
title: "1000 小时",
description: "用注意力填满 1000 小时就能练成任何你需要的技能……",
head: [
[
"script",
{
async: "",
src: "https://www.googletagmanager.com/gtag/js?id=G-Z2QZPX3T9W",
},
],
[
"script",
{},
`window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-Z2QZPX3T9W');`,
],
["link", { rel: "icon", href: "/images/clock.svg" }],
],
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: "Home", link: "/" },
{ text: "Enjoy App", link: "/enjoy-app/", activeMatch: "/enjoy-app/" },
],
search: {
// provider: 'local'
provider: "algolia",
options: {
appId: "KKK8CORNSR",
apiKey: "d613ff31a535ff1e9535cf9c88ec420a",
indexName: "1000h",
},
},
sidebar: {
"/": [
{
text: "简要说明",
collapsed: true,
link: "/intro",
items: [
{ text: "1. 要不要健脑?", link: "/why" },
{ text: "2. 什么最健脑?", link: "/what" },
],
},
{
text: "训练任务",
collapsed: true,
items: [
{ text: "1. 启动任务", link: "/training-tasks/kick-off" },
{ text: "2. 训练方法", link: "/training-tasks/procedures" },
{
text: "3. 人工智能",
collapsed: false,
link: "/training-tasks/ai",
items: [
{
text: "3.1. 基础语言能力",
link: "/training-tasks/language",
},
{
text: "3.2. 成年人的困境",
link: "/training-tasks/predicaments",
},
{
text: "3.3. 人工智能辅助",
link: "/training-tasks/revolution",
},
{ text: "3.4. 任务并不高级", link: "/training-tasks/ground" },
{ text: "3.5. 效果非常惊人", link: "/training-tasks/wonder" },
],
},
{ text: "4. 意料之外", link: "/training-tasks/surprise" },
],
},
{
text: "语音塑造",
link: "/sounds-of-american-english/1-basics",
collapsed: true,
items: [
{
text: "1. 基础",
collapsed: true,
link: "/sounds-of-american-english/1-basics",
items: [
{
text: "1.1. 字母",
link: "/sounds-of-american-english/1.1-alphabet",
},
{
text: "1.2. 音素",
link: "/sounds-of-american-english/1.2-phonemes",
},
{
text: "1.3. 口音",
link: "/sounds-of-american-english/1.3-accents",
},
{
text: "1.4. 器官",
link: "/sounds-of-american-english/1.4-articulators",
},
],
},
{
text: "2. 详解",
collapsed: true,
link: "/sounds-of-american-english/2-details",
items: [
{
text: "2.1. 元音",
collapsed: true,
link: "/sounds-of-american-english/2.1-vowels",
items: [
{
text: "2.1.1. 口型",
link: "/sounds-of-american-english/2.1.1-lips",
},
{
text: "2.1.2. 舌位",
link: "/sounds-of-american-english/2.1.2-tongue",
},
{
text: "2.1.3. ʌ/ɑː/ɑːr",
link: "/sounds-of-american-english/2.1.3-ʌ",
},
{
text: "2.1.4. e/æ",
link: "/sounds-of-american-english/2.1.4-e",
},
{
text: "2.1.5. ə/ɚ/ɝː",
link: "/sounds-of-american-english/2.1.5-ə",
},
{
text: "2.1.6. ɪ/i/iː",
link: "/sounds-of-american-english/2.1.6-i",
},
{
text: "2.1.7. ʊ/u/uː",
link: "/sounds-of-american-english/2.1.7-u",
},
{
text: "2.1.8. ɑː/ɔː/ɔːr",
link: "/sounds-of-american-english/2.1.8-ɔ",
},
{
text: "2.1.9. aɪ... əʊ",
link: "/sounds-of-american-english/2.1.9-aɪ",
},
{
text: "2.1.10. ɤ",
link: "/sounds-of-american-english/2.1.10-ɤ",
},
]
},
{
text: "2.2. 辅音",
collapsed: true,
link: "/sounds-of-american-english/2.2-consonants",
items: [
{
text: "2.2.1. 分类",
link: "/sounds-of-american-english/2.2.1-categorization",
},
{
text: "2.2.2. p/b",
link: "/sounds-of-american-english/2.2.2-pb",
},
{
text: "2.2.3. t/d",
link: "/sounds-of-american-english/2.2.3-td",
},
{
text: "2.2.4. k/g",
link: "/sounds-of-american-english/2.2.4-kg",
},
{
text: "2.2.5. f/v",
link: "/sounds-of-american-english/2.2.5-fv",
},
{
text: "2.2.6. s/z",
link: "/sounds-of-american-english/2.2.6-sz",
},
{
text: "2.2.7. θ/ð",
link: "/sounds-of-american-english/2.2.7-θð",
},
{
text: "2.2.8. ʃ/ʒ",
link: "/sounds-of-american-english/2.2.8-ʃʒ",
},
{
text: "2.2.9. h",
link: "/sounds-of-american-english/2.2.9-h",
},
{
text: "2.2.10. tʃ/dʒ",
link: "/sounds-of-american-english/2.2.10-tʃdʒ",
},
{
text: "2.2.11. tr/dr",
link: "/sounds-of-american-english/2.2.11-trdr",
},
{
text: "2.2.12. ts/dz",
link: "/sounds-of-american-english/2.2.12-tsdz",
},
{
text: "2.2.13. m, n, ŋ",
link: "/sounds-of-american-english/2.2.13-mnŋ",
},
{
text: "2.2.14. l, r",
link: "/sounds-of-american-english/2.2.14-lr",
},
{
text: "2.2.15. w, j",
link: "/sounds-of-american-english/2.2.15-wj",
},
]
},
{
text: "2.3. 音节",
collapsed: true,
link: "/sounds-of-american-english/2.3-syllables",
items: [
{
text: "2.3.1. 构成",
link: "/sounds-of-american-english/2.3.1-structure",
},
{
text: "2.3.2. 重音",
link: "/sounds-of-american-english/2.3.2-stress",
},
]
},
{
text: "2.4. 连接",
collapsed: true,
link: "/sounds-of-american-english/2.4-linking",
items: [
{
text: "2.4.1. 停顿",
link: "/sounds-of-american-english/2.4.1-stop",
},
{
text: "2.4.2. 辅音 + 元音",
link: "/sounds-of-american-english/2.4.2-cv",
},
{
text: "2.4.3. 辅音 + 辅音",
link: "/sounds-of-american-english/2.4.3-cc",
},
{
text: "2.4.4. 元音 + 元音",
link: "/sounds-of-american-english/2.4.4-vv",
},
]
},
{
text: "2.5. 韵律",
collapsed: true,
link: "/sounds-of-american-english/2.5-prosody",
items: [
{
text: "2.5.1. 高低",
link: "/sounds-of-american-english/2.5.1-pitch",
},
{
text: "2.5.2. 起伏",
link: "/sounds-of-american-english/2.5.2-tone",
},
{
text: "2.5.3. 轻重",
link: "/sounds-of-american-english/2.5.3-emphasis",
},
{
text: "2.5.4. 缓急",
link: "/sounds-of-american-english/2.5.4-pace",
},
]
},
],
},
{
text: "3. 收官",
collapsed: true,
link: "/sounds-of-american-english/3-wrapping-up",
items: [
{
text: "3.1. 流利",
link: "/sounds-of-american-english/3.1-fluency",
},
{
text: "3.2. 情绪",
link: "/sounds-of-american-english/3.2-emotions",
},
],
},
{
text: "4. 而后",
collapsed: true,
link: "/sounds-of-american-english/4-whats-next",
items: [
{
text: "4.1. 多音拼写",
link: "/sounds-of-american-english/4.1-multisounds",
},
{
text: "4.2. 组合词汇",
link: "/sounds-of-american-english/4.2-compounds",
},
{
text: "4.3. 词根词缀",
collapsed: false,
link: "/sounds-of-american-english/4.3-components",
items: [
{
text: "4.3.1. 常见前缀",
link: "/sounds-of-american-english/4.3.1-prefixes",
},
{
text: "4.3.2. 常见后缀",
link: "/sounds-of-american-english/4.3.2-suffixes",
},
{
text: "4.3.3. 常见词根",
link: "/sounds-of-american-english/4.3.3-roots",
},
],
},
],
},
{
text: "5. 总结",
link: "/sounds-of-american-english/5-sumup",
},
],
},
// {
// text: "语音塑造",
// collapsed: true,
// items: [
// {
// text: "1. 基础",
// collapsed: true,
// link: "/sounds-of-english/0-intro",
// items: [
// {
// text: "1.1. 音素",
// collapsed: true,
// link: "/sounds-of-english/01-phonemes",
// items: [
// {
// text: "1.1.1. 元音",
// link: "/sounds-of-english/01-1-vowels",
// },
// {
// text: "1.1.2. 辅音",
// link: "/sounds-of-english/01-2-consonants",
// },
// {
// text: "1.1.3. 美式语音标注",
// link: "/sounds-of-english/01-3-us-phonemes",
// },
// {
// text: "1.1.4. 示例",
// link: "/sounds-of-english/01-4-pangram",
// },
// ],
// },
// {
// text: "1.2. 音节",
// link: "/sounds-of-english/02-syllables",
// },
// ],
// },
// {
// text: "2. 详解",
// collapsed: true,
// link: "/sounds-of-english/03-details",
// items: [
// {
// text: "2.1. 元音",
// collapsed: false,
// link: "/sounds-of-english/03-vowels-overview",
// items: [
// {
// text: "2.1.1. 口腔内气流共鸣位置",
// link: "/sounds-of-english/04-vowel-positions",
// },
// { text: "2.1.2. ʌ/ɑː", link: "/sounds-of-english/05-Ʌ" },
// { text: "2.1.3. e/æ", link: "/sounds-of-english/06-e" },
// { text: "2.1.4. ə/əː", link: "/sounds-of-english/07-ə" },
// { text: "2.1.5. ɪ/iː", link: "/sounds-of-english/08-i" },
// { text: "2.1.6. ʊ/uː", link: "/sounds-of-english/09-u" },
// { text: "2.1.7. ɔ/ɔː", link: "/sounds-of-english/10-ɔ" },
// {
// text: "2.1.8. aɪ, eɪ, ɔɪ, aʊ, əʊ, eə, ɪə, ʊə",
// link: "/sounds-of-english/11-aɪ",
// },
// ],
// },
// {
// text: "2.2. 辅音",
// collapsed: false,
// link: "/sounds-of-english/12-consonants-overview",
// items: [
// {
// text: "2.2.1. p, b, m, n, f, k, g, h",
// link: "/sounds-of-english/13-pbmnfkgh",
// },
// { text: "2.2.2. f, v", link: "/sounds-of-english/14-fv" },
// {
// text: "2.2.3. m, n, ŋ",
// link: "/sounds-of-english/15-mn",
// },
// {
// text: "2.2.4. t, d, s, z; ʃ, tʃ, dʒ",
// link: "/sounds-of-english/16-tdsz",
// },
// { text: "2.2.5. t, d", link: "/sounds-of-english/17-td" },
// {
// text: "2.2.6. tr, dr, ts, dz",
// link: "/sounds-of-english/18-trdr",
// },
// {
// text: "2.2.7. sp, st, str, sk",
// link: "/sounds-of-english/19-sptk",
// },
// { text: "2.2.8. h", link: "/sounds-of-english/20-h" },
// { text: "2.2.9. θ, ð", link: "/sounds-of-english/21-θð" },
// { text: "2.2.10. r", link: "/sounds-of-english/22-r" },
// { text: "2.2.11. l", link: "/sounds-of-english/23-l" },
// { text: "2.2.12. ʒ", link: "/sounds-of-english/24-ʒ" },
// {
// text: "2.2.13. j, w",
// link: "/sounds-of-english/25-jw",
// },
// ],
// },
// {
// text: "2.3. 连读",
// link: "/sounds-of-english/26-catenation",
// },
// {
// text: "2.4. 音标学习",
// link: "/sounds-of-english/27-learning-phonetics",
// },
// {
// text: "2.4. 英美口音选择",
// link: "/sounds-of-english/28-choosing-accent",
// },
// ],
// },
// {
// text: "3. 进阶",
// collapsed: true,
// link: "/sounds-of-english/29-advanced",
// items: [
// {
// text: "3.1 什么更重要?",
// link: "/sounds-of-english/30-more-important",
// },
// { text: "3.2 停顿", link: "/sounds-of-english/31-pause" },
// { text: "3.3 高低", link: "/sounds-of-english/32-high-low" },
// { text: "3.4 起伏", link: "/sounds-of-english/33-up-down" },
// {
// text: "3.5 轻重",
// link: "/sounds-of-english/34-strong-weak",
// },
// { text: "3.6 缓急", link: "/sounds-of-english/35-fast-slow" },
// {
// text: "3.7 长短",
// link: "/sounds-of-english/36-long-short",
// },
// ],
// },
// {
// text: "4. 收官",
// collapsed: true,
// link: "/sounds-of-english/37-round-up",
// items: [
// { text: "4.1 流利", link: "/sounds-of-english/38-fluent" },
// { text: "4.2 情绪", link: "/sounds-of-english/39-emotional" },
// ],
// },
// ],
// },
{
text: "大脑内部",
collapsed: true,
items: [
{ text: "1. 小空间大世界", link: "/in-the-brain/01-inifinite" },
{ text: "2. 一切都是连接", link: "/in-the-brain/02-links" },
{ text: "3. 一切都是体育课", link: "/in-the-brain/03-sports" },
{
text: "4. 一切都是语文课",
link: "/in-the-brain/04-literature",
},
{ text: "5. 一切都需要能量", link: "/in-the-brain/05-energy" },
{
text: "6. 用进废退循环利用",
link: "/in-the-brain/06-use-or-lose",
},
{
text: "7. 短时间内足量重复",
link: "/in-the-brain/07-repitition",
},
{
text: "8. 新旧网络间的竞争",
link: "/in-the-brain/08-compitition",
},
{
text: "9. 注意不到就不存在",
link: "/in-the-brain/09-unnoticed",
},
{
text: "10. 熟练就是卸载负担",
link: "/in-the-brain/10-unloading",
},
{ text: "11. 被关注是最大负担", link: "/in-the-brain/11-burden" },
{
text: "12. 有限排它不可再生",
link: "/in-the-brain/12-unreproducible",
},
{
text: "13. 一切都是化学反应",
link: "/in-the-brain/13-chemical",
},
{
text: "14. 安全阈值决定成果",
link: "/in-the-brain/14-threshold",
},
],
},
{
text: "自我训练",
collapsed: true,
link: `/self-training/00-intro`,
items: [
{ text: "1. 用兵打仗", link: "/self-training/01-fight" },
{ text: "2. 只能自学", link: "/self-training/02-last-resort" },
{
text: "3. 生学硬练",
link: "/self-training/03-trials-and-errors",
},
{ text: "4. 走出迷宫", link: "/self-training/04-maze" },
{ text: "5. 自我纠正", link: "/self-training/05-correction" },
{ text: "6. 自主驱动", link: "/self-training/06-motives" },
{ text: "7. 自我鼓励", link: "/self-training/07-encouraging" },
{ text: "8. 自我监督", link: "/self-training/08-supervising" },
{ text: "9. 自主计划", link: "/self-training/09-planning" },
{ text: "10. 返璞归真", link: "/self-training/10-going-back" },
],
},
{
text: "Enjoy App",
collapsed: true,
link: `/enjoy-app/`,
items: [
{
text: "快速开始",
collapsed: false,
items: [
{ text: "Enjoy 简介", link: "/enjoy-app/" },
{ text: "下载安装", link: "/enjoy-app/install" },
{ text: "软件设置", link: "/enjoy-app/settings" },
],
},
{
text: "跟读训练",
collapsed: false,
items: [
{ text: "音频资源", link: "/enjoy-app/audios" },
{ text: "视频资源", link: "/enjoy-app/videos" },
],
},
{
text: "阅读文本",
collapsed: false,
items: [
{ text: "在线文章", link: "/enjoy-app/webpage" },
{ text: "本地电子书", link: "/enjoy-app/ebook" },
],
},
{
text: "智能助手",
collapsed: false,
items: [
{ text: "简介", link: "/enjoy-app/ai-assistant" },
{ text: "GPT 服务", link: "/enjoy-app/gpt-conversation" },
{ text: "TTS 服务", link: "/enjoy-app/tts-conversation" },
],
},
{
text: "其他",
collapsed: false,
items: [
{
text: "常见问题",
link: "/enjoy-app/faq",
},
{
text: "利用 AI 生成训练材料",
link: "/enjoy-app/use-case-generate-audio-resources",
},
],
},
]
}
],
"/enjoy-app/": [
{
text: "快速开始",
collapsed: false,
items: [
{ text: "Enjoy 简介", link: "/enjoy-app/" },
{ text: "下载安装", link: "/enjoy-app/install" },
{ text: "软件设置", link: "/enjoy-app/settings" },
{ text: "版本更新", link: "/enjoy-app/changelog" },
],
},
{
text: "跟读训练",
collapsed: false,
items: [
{ text: "音频资源", link: "/enjoy-app/audios" },
{ text: "视频资源", link: "/enjoy-app/videos" },
],
},
{
text: "阅读文本",
collapsed: false,
items: [
{ text: "在线文章", link: "/enjoy-app/webpage" },
{ text: "本地电子书", link: "/enjoy-app/ebook" },
],
},
{
text: "智能助手",
collapsed: false,
items: [
{ text: "简介", link: "/enjoy-app/ai-assistant" },
{ text: "GPT 服务", link: "/enjoy-app/gpt-conversation" },
{ text: "TTS 服务", link: "/enjoy-app/tts-conversation" },
],
},
{
text: "其他",
collapsed: false,
items: [
{
text: "常见问题",
link: "/enjoy-app/faq",
},
{
text: "利用 AI 生成训练材料",
link: "/enjoy-app/use-case-generate-audio-resources",
},
],
},
{
text: "返回",
link: "/intro",
},
],
},
socialLinks: [
{
icon: "github",
link: "https://github.com/zuodaotech/everyone-can-use-english/tree/main/1000-hours",
},
],
},
markdown: {
// https://vitepress.dev/reference/markdown
math: true,
config: (md) => {
// use more markdown-it plugins!
md.use(footnote);
md.use(sub);
md.use(sup);
md.use(mark);
md.use(ins);
},
// toc: {
// level: [2, 3, 4]
// }
},
})
);

View File

@@ -147,7 +147,6 @@ export default withMermaid(
collapsed: true,
link: "/sounds-of-american-english/3.2-consonants",
items: [
{
text: "3.2.1. p/b",
link: "/sounds-of-american-english/3.2.1-pb",
@@ -247,6 +246,29 @@ export default withMermaid(
text: "7. 从此之后",
link: "/sounds-of-american-english/7-whats-next",
},
{
text: "8. 附录",
collapsed: true,
link: "/sounds-of-american-english/8-appendix",
items: [
{
text: "8.1. 输入音标与特殊符号",
link: "/sounds-of-american-english/8.1-inputting-phonemes-and-symbols",
},
{
text: "8.2. 获取 CEPD 音标",
link: "/sounds-of-american-english/8.2-cepd-phonetics-and-sound",
},
{
text: "8.3. 音标练习",
link: "/sounds-of-american-english/8.3-phoneme-exercises",
},
{
text: "8.4. 每日练习语音生成",
link: "/sounds-of-american-english/8.4-daily-speech-exercises",
},
],
},
],
},
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

File diff suppressed because one or more lines are too long

View File

@@ -1247,7 +1247,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.4"
}
},
"nbformat": 4,

View File

@@ -0,0 +1,188 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%pip install python-vlc"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"import json\n",
"import vlc\n",
"import re\n",
"import random\n",
"from IPython.display import Audio\n",
"\n",
"import json\n",
"import requests\n",
"\n",
"def load_json_database(source):\n",
" records = []\n",
" \n",
" def parse_json_lines(lines):\n",
" for line in lines:\n",
" if line:\n",
" try:\n",
" record = json.loads(line)\n",
" records.append(record)\n",
" except json.JSONDecodeError as e:\n",
" print(f\"Error parsing JSON: {e}\")\n",
"\n",
" try:\n",
" if source.startswith('http://') or source.startswith('https://'):\n",
" # Handle as URL\n",
" response = requests.get(source)\n",
" response.raise_for_status() # Raise an error for bad status codes\n",
" parse_json_lines(response.iter_lines(decode_unicode=True))\n",
" else:\n",
" # Handle as file\n",
" with open(source, 'r', encoding='utf-8') as file:\n",
" parse_json_lines(file)\n",
" except requests.exceptions.RequestException as e:\n",
" print(f\"Error fetching data from URL: {e}\")\n",
" except FileNotFoundError as e:\n",
" print(f\"Error opening file: {e}\")\n",
" except Exception as e:\n",
" print(f\"An unexpected error occurred: {e}\")\n",
" \n",
" return records\n",
"\n",
"url = \"https://raw.githubusercontent.com/zelic91/camdict/main/cam_dict.refined.json\"\n",
"json_database = load_json_database(url)\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"def search_in_json_database(database, search_word, region):\n",
" for record in database:\n",
" # 检查 word 字段是否匹配\n",
" if record.get('word') == search_word:\n",
" # 找到匹配项后,获取美式发音信息\n",
" pos_items = record.get('pos_items', [])\n",
" for pos_item in pos_items:\n",
" pronunciations = pos_item.get('pronunciations', [])\n",
" for pronunciation in pronunciations:\n",
" if pronunciation.get('region') == region:\n",
" # 找到美式发音,返回相关信息\n",
" return {\n",
" 'pronunciation': pronunciation.get('pronunciation'),\n",
" 'audio': pronunciation.get('audio')\n",
" }\n",
" # 如果没有找到匹配的 word 字段,返回 'not exist'\n",
" return 'not exist'\n",
"\n",
"def replace_with_underscores(match):\n",
" return '_' * len(match.group(0))"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"broadband\n",
"https://dictionary.cambridge.org/media/english/us_pron/c/cus/cus00/cus00276.mp3\n",
"Fill vowels in blanks: ˈbr__d.b_nd\n",
"Fill in consonants in blanks: ˈ__ɑː_._æ__\n"
]
},
{
"data": {
"text/html": [
"\n",
" <audio controls=\"controls\" >\n",
" <source src=\"https://dictionary.cambridge.org/media/english/us_pron/c/cus/cus00/cus00276.mp3\" type=\"audio/mpeg\" />\n",
" Your browser does not support the audio element.\n",
" </audio>\n",
" "
],
"text/plain": [
"<IPython.lib.display.Audio object>"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# get a random word from the database\n",
"\n",
"vowel_phonetics = re.compile(r'ɑː|ɑːr|ʌ||iː|ɪ|i|ɪr|ʊ|ʊr|uː|ʊr|e|er|æ|ə|ɚ|ɝː|ɒ|ɔː|ɔːr|ɔɪ|aɪ|aɪr|eɪ|aʊ|aʊr|oʊ|')\n",
"consonant_phonetics = re.compile(r'p|b|t|d|k|ɡ|f|v|θ|ð|s|z|ʃ|ʒ|tʃ|dʒ|r|h|l|t̬|j|w|ŋ|n|m|tr|dr|ts|dz|br|pr|fr|ɡr|θr|dr|ʃr|kr|bl|kl|ɡl|fl|pl|sl|sp|st|sk|sm|sn|sw|str|spr|skr|spl|sfr|skw|skr|skl|')\n",
"\n",
"# if the word is with certain enddings such as 'es, ed, ing', get another word\n",
"random_word = random.choice(json_database)\n",
"while random_word['word'].endswith(('ed', 'ing', 'es', 'ts', 'ks', 'ds', 'ps', 'bs', 'gs', 'ls', 'rs', 'ms', 'ns', 'er', 'est')):\n",
" random_word = random.choice(json_database)\n",
"\n",
"# get pronunciation of the random word with region 'us'\n",
"random_word_us = search_in_json_database(json_database, random_word['word'], 'us')\n",
"\n",
"# get the word's phonetics\n",
"random_word_entry = random_word['word']\n",
"print(random_word_entry)\n",
"\n",
"random_word_phonetics = random_word_us['pronunciation']\n",
"\n",
"# get the audio url of the word\n",
"random_word_us_audio_url = random_word_us['audio']\n",
"print(random_word_us_audio_url)\n",
"\n",
"blank_vowel_phonetics = re.sub(vowel_phonetics, replace_with_underscores, random_word_phonetics)\n",
"blank_consonant_phonetics = re.sub(consonant_phonetics, replace_with_underscores, random_word_phonetics)\n",
"\n",
"# fill vowels in blanks\n",
"print(f'Fill vowels in blanks: {blank_vowel_phonetics}')\n",
"\n",
"# fill consonants in blanks\n",
"print(f'Fill in consonants in blanks: {blank_consonant_phonetics}')\n",
"\n",
"# play the audio\n",
"player = vlc.MediaPlayer(random_word_us['audio'])\n",
"player.play()\n",
"\n",
"# display the audio\n",
"Audio(url=random_word_us_audio_url)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

View File

@@ -359,9 +359,9 @@
</tr>
<tr>
<td><span class="pho">ŋ</span><span class="speak-word-inline" data-audio-uk-male="/audios/uk_phonetics_sound_sing_2023feb.mp3"></span></td>
<td><b>th</b>ank <span class="pho alt not-display">θæŋk</span><span class="speak-word-inline" data-audio-uk-female="/audios/thank-uk-female.mp3" data-audio-uk-male="/audios/thank-uk-male.mp3"></span></td>
<td>tha<b>n</b>k <span class="pho alt not-display">θæŋk</span><span class="speak-word-inline" data-audio-uk-female="/audios/thank-uk-female.mp3" data-audio-uk-male="/audios/thank-uk-male.mp3"></span></td>
<td><span class="pho">ŋ</span><span class="speak-word-inline" data-audio-us-male="/audios/us_phonetics_sound_sing_2023feb.mp3"></span></td>
<td><b>th</b>ank <span class="pho alt not-display">θæŋk</span><span class="speak-word-inline" data-audio-us-female="/audios/thank-us-female.mp3" data-audio-us-male="/audios/thank-us-male.mp3"></span></td>
<td>tha<b>n</b>k <span class="pho alt not-display">θæŋk</span><span class="speak-word-inline" data-audio-us-female="/audios/thank-us-female.mp3" data-audio-us-male="/audios/thank-us-male.mp3"></span></td>
</tr>
<tr>
<td><span class="pho">l</span><span class="speak-word-inline" data-audio-uk-male="/audios/uk_phonetics_sound_look_2023feb.mp3"></span></td>

View File

@@ -28,9 +28,9 @@
</tr>
<tr>
<td><span class="pho">ŋ</span><span class="speak-word-inline" data-audio-uk-male="/audios/uk_phonetics_sound_sing_2023feb.mp3"></span></td>
<td><b>th</b>ank <span class="pho alt">θæŋk</span><span class="speak-word-inline" data-audio-uk-female="/audios/thank-uk-female.mp3" data-audio-uk-male="/audios/thank-uk-male.mp3"></span></td>
<td>tha<b>n</b>k <span class="pho alt">θæŋk</span><span class="speak-word-inline" data-audio-uk-female="/audios/thank-uk-female.mp3" data-audio-uk-male="/audios/thank-uk-male.mp3"></span></td>
<td><span class="pho">ŋ</span><span class="speak-word-inline" data-audio-us-male="/audios/us_phonetics_sound_sing_2023feb.mp3"></span></td>
<td><b>th</b>ank <span class="pho alt">θæŋk</span><span class="speak-word-inline" data-audio-us-female="/audios/thank-us-female.mp3" data-audio-us-male="/audios/thank-us-male.mp3"></span></td>
<td>tha<b>n</b>k <span class="pho alt">θæŋk</span><span class="speak-word-inline" data-audio-us-female="/audios/thank-us-female.mp3" data-audio-us-male="/audios/thank-us-male.mp3"></span></td>
</tr>
</tbody>
</table>

View File

@@ -0,0 +1,3 @@
# 附录
这里补充的是一些日常可以使用的桌面版工具。

View File

@@ -0,0 +1,63 @@
# 8.1. 输入音标与特殊符号
在电子文档中输入音标符号(及其其它特殊符号)从来都很麻烦。
再一次,我用 Alfred 作为辅助,以下是 workflow 文件:
> [IPA-Phonetic-Symbols](https:///1000h.org/public/alfred-workflows/IPA-Phonetic-Symbols.alfredworkflow)
以启动关键字 `ipae` 为例 —— 呼出 Alfred
![ipae](/images/ipae.png)
这时,就可以用 `CMD + 数字` 的方式,将对应的符号插入当前文本。比如,`CMD + 4` 就是将 <span class="pho">ɝː</span> 插入当前文本编辑器。
以下罗列的是各个符号对应的 Alfred 关键字Keywords
| 关键字Keyword | 符号Symbol |
| ----- | ----- |
| `ipaa` | <span class="pho">ʌ</span> |
| `ipaaa` | <span class="pho">ɑ</span> |
| `ipaae` | <span class="pho">æ</span> |
| `ipae` | <span class="pho">ə</span> |
| `ipaeeer` | <span class="pho">ɝː</span> |
| `ipaer` | <span class="pho">ɚ</span> |
| `ipaes` | <span class="pho">ᵊ</span> |
| `ipai` | <span class="pho">ɪ</span> |
| `ipau` | <span class="pho">ʊ</span> |
| `ipao` | <span class="pho">ɒ</span> |
| `ipaoo` | <span class="pho">ɔ</span> |
| `ipal` | <span class="pho">ɤ</span> |
| `ipatd` | <span class="pho">t̠</span> |
| `ipatg` | <span class="pho">ʔ</span> |
| `ipats` | <span class="pho">ᵗ</span> |
| `ipan` | <span class="pho">ŋ</span> |
| `ipath` | <span class="pho">θ</span> |
| `ipad` | <span class="pho">ð</span> |
| `ipas` | <span class="pho">ʃ</span> |
| `ipaz` | <span class="pho">ʒ</span> |
| `ipaj` | <span class="pho">ʲ</span> |
| `ipaw` | <span class="pho">ʷ</span> |
| `ipa1` | <span class="pho">◌̅</span> flat |
| `ipa2` | <span class="pho">◌́</span> rise |
| `ipa3` | <span class="pho">◌̌</span> fall-rise |
| `ipa4` | <span class="pho">◌̀</span> fall |
| `ipa5` | <span class="pho">◌̂</span> pitch raise |
| `ipa6` | <span class="pho">◌̲</span> long vowel |
| `ipa7` | <span class="pho">◌̩</span> syllabic consonant |
| `ipa8` | <span class="pho">◌̥</span> voiceless |
| `ipa9` | <span class="pho">◌̚</span> stop |
| `ipa0` | <span class="pho">◌</span> |
| `ipa`: | <span class="pho">ː</span> long vowel symbol |
| `ipa`" | <span class="pho">ˈ</span> prime stress |
| `ipa`' | <span class="pho">ˌ</span> secondary stress |
| `ipa-` | <span class="pho">◌‿◌</span> linking |
| `ipa\|` | <span class="pho">‖</span> grouping boundary |
| `-->` | <span class="pho">⭢</span> |
| `<--` | <span class="pho">⭠</span> |
| `<->` | <span class="pho">⭤</span> |
| `irise` | <span class="pho">⤴</span> senetence intonation rise |
| `idown` | <span class="pho">⤵</span> senetence intonation fall |

View File

@@ -0,0 +1,110 @@
# 8.2. 获取 CEPD 音标
macOS 上有一个收费软件,[Alfred](https://www.alfredapp.com/)可以用来定义很多快捷流程workflow去完成相对复杂的任务。比如通过设定关键字启动一个 Python 脚本查询某个单词甚至整个句子在《剑桥英语发声词典》CEPD中的音标。
> Alfred 的使用方法,参见:
> https://github.com/xiaolai/apple-computer-literacy/blob/main/alfred.md
在 Github 上有一个开源的仓库,提供了《剑桥英语发声词典》的 json 格式数据库:
> https://github.com/zelic91/camdict
将这个仓库里的 [cam_dict.refined.json](https://github.com/zelic91/camdict/raw/main/cam_dict.refined.json) 下载并保存到本地某个位置。
我写了一个 Alfred 的 workflow使用的是 macOS 系统自带的 python3`/usr/bin/python3`
> [CEPD-phonetic-transcription.alfredworkflow](https:///1000h.org/public/alfred-workflows/CEPD-phonetic-transcription.alfredworkflow)
下载这个文件之后,导入 Alfred。
在使用之前要注意:
> * 修改各个 Python 脚本内的 `cam_dict.refined.json` 的文件路径
这个 workflow 可用的启动关键字分别是:
> * `cams`:查询音标(美式发音)
> * `camk`:查询音标(英式发音)
> * `camsd`:用浏览器打开 CEPD 真人示范录音(美式发音)在线网址
> * `camsd`:用浏览器打开 CEPD 真人示范录音(英式发音)在线网址
> * `camw`:用浏览器打开 CEPD 查询页面
> * `ipa`:返回 CMU卡耐基梅隆大学音标库中的音标
以下是查询音标的 workflow启动关键字为 `cams`)中的 python 脚本:
```python
#
# NOTE: Python 2 is deprecated in macOS, and has been removed from macOS 12.3+
#
import sys
import json
# 假设你的 JSON 数据库是一个 JSON 文件,我们将从文件中加载数据
# 如果 JSON 数据在内存中或其他格式,你可能需要修改这部分代码
def load_json_database(file_path):
records = []
with open(file_path, 'r') as file:
for line in file:
try:
record = json.loads(line)
records.append(record)
except json.JSONDecodeError as e:
print(f"Error parsing JSON: {e}")
return records
# 在 JSON 数据库中检索 word
def search_in_json_database(database, search_word, region):
for record in database:
# 检查 word 字段是否匹配
if record.get('word') == search_word:
# 找到匹配项后,获取美式发音信息
pos_items = record.get('pos_items', [])
for pos_item in pos_items:
pronunciations = pos_item.get('pronunciations', [])
for pronunciation in pronunciations:
if pronunciation.get('region') == region:
# 找到美式发音,返回相关信息
return {
'pronunciation': pronunciation.get('pronunciation'),
'audio': pronunciation.get('audio')
}
# 如果没有找到匹配的 word 字段,返回 'not exist'
return 'not exist'
# cam_dict.refined.json 的文件路径
json_db_file_path = '/Users/joker/github/camdict/cam_dict.refined.json'
# 要检索的单词
search_word = sys.argv[1]
region = "us"
json_database = load_json_database(json_db_file_path)
# replace punctuations in text with space
punctuations = ",.?!;"
for p in punctuations:
search_word = search_word.replace(p, " ")
words = [word for word in search_word.split() if word.strip() != '']
phonetics = []
for w in words:
# 检索并获取结果
w = w.strip().lower()
if w[-1] in punctuations:
w = w.rstrip(",.?!;")
result = search_in_json_database(json_database, w, region)
if result == 'not exist':
phonetics.append(w+"*")
else:
phonetics.append(result['pronunciation'])
returnvalue = ''
for p in phonetics:
returnvalue += p + ' '
sys.stdout.write(returnvalue.strip())
```

View File

@@ -0,0 +1,127 @@
# 8.3. 音标练习
这是一个 Jupyter Notebook用来建立音标符号与声音之间的关联。
每次执行,随即从《剑桥英语发声词典》中选取一个词汇,播放真人朗读语音,而后要求对元音或者辅音填空……
> [phonetics-fill-in-exercise.ipynb](https://1000h.org/public/jupyter-notebooks/phonetics-fill-in-exercise.ipynb)
执行结果如下:
![phoneme-exercises.png](/images/phoneme-exercises.png)
Jupyter Notebook 代码如下:
``` Python
# %%
%pip install python-vlc
# %%
import requests
import json
import vlc
import re
import random
from IPython.display import Audio
import json
import requests
def load_json_database(source):
records = []
def parse_json_lines(lines):
for line in lines:
if line:
try:
record = json.loads(line)
records.append(record)
except json.JSONDecodeError as e:
print(f"Error parsing JSON: {e}")
try:
if source.startswith('http://') or source.startswith('https://'):
# Handle as URL
response = requests.get(source)
response.raise_for_status() # Raise an error for bad status codes
parse_json_lines(response.iter_lines(decode_unicode=True))
else:
# Handle as file
with open(source, 'r', encoding='utf-8') as file:
parse_json_lines(file)
except requests.exceptions.RequestException as e:
print(f"Error fetching data from URL: {e}")
except FileNotFoundError as e:
print(f"Error opening file: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
return records
url = "https://raw.githubusercontent.com/zelic91/camdict/main/cam_dict.refined.json"
json_database = load_json_database(url)
# %%
def search_in_json_database(database, search_word, region):
for record in database:
# 检查 word 字段是否匹配
if record.get('word') == search_word:
# 找到匹配项后,获取美式发音信息
pos_items = record.get('pos_items', [])
for pos_item in pos_items:
pronunciations = pos_item.get('pronunciations', [])
for pronunciation in pronunciations:
if pronunciation.get('region') == region:
# 找到美式发音,返回相关信息
return {
'pronunciation': pronunciation.get('pronunciation'),
'audio': pronunciation.get('audio')
}
# 如果没有找到匹配的 word 字段,返回 'not exist'
return 'not exist'
def replace_with_underscores(match):
return '_' * len(match.group(0))
# %%
# get a random word from the database
vowel_phonetics = re.compile(r'ɑː|ɑːr|ʌ||iː|ɪ|i|ɪr|ʊ|ʊr|uː|ʊr|e|er|æ|ə|ɚ|ɝː|ɒ|ɔː|ɔːr|ɔɪ|aɪ|aɪr|eɪ|aʊ|aʊr|oʊ|')
consonant_phonetics = re.compile(r'p|b|t|d|k|ɡ|f|v|θ|ð|s|z|ʃ|ʒ|tʃ|dʒ|r|h|l|t̬|j|w|ŋ|n|m|tr|dr|ts|dz|br|pr|fr|ɡr|θr|dr|ʃr|kr|bl|kl|ɡl|fl|pl|sl|sp|st|sk|sm|sn|sw|str|spr|skr|spl|sfr|skw|skr|skl|')
# if the word is with certain enddings such as 'es, ed, ing', get another word
random_word = random.choice(json_database)
while random_word['word'].endswith(('ed', 'ing', 'es', 'ts', 'ks', 'ds', 'ps', 'bs', 'gs', 'ls', 'rs', 'ms', 'ns', 'er', 'est')):
random_word = random.choice(json_database)
# get pronunciation of the random word with region 'us'
random_word_us = search_in_json_database(json_database, random_word['word'], 'us')
# get the word's phonetics
random_word_entry = random_word['word']
print(random_word_entry)
random_word_phonetics = random_word_us['pronunciation']
# get the audio url of the word
random_word_us_audio_url = random_word_us['audio']
print(random_word_us_audio_url)
blank_vowel_phonetics = re.sub(vowel_phonetics, replace_with_underscores, random_word_phonetics)
blank_consonant_phonetics = re.sub(consonant_phonetics, replace_with_underscores, random_word_phonetics)
# fill vowels in blanks
print(f'Fill vowels in blanks: {blank_vowel_phonetics}')
# fill consonants in blanks
print(f'Fill in consonants in blanks: {blank_consonant_phonetics}')
# play the audio
player = vlc.MediaPlayer(random_word_us['audio'])
player.play()
# display the audio
Audio(url=random_word_us_audio_url)
```

View File

@@ -0,0 +1,10 @@
# 8.4. 每日练习语音生成
这是一个 Jupyter Notebook —— 需要有自己的 OpenAI API Key。指定 `user-prompt`,而后生成
> * 一个篇章及其 markdown 文件,以及由 alloy 和 nova 朗读的 mp3 文件
> * 同一话题的两个对话,及其 mp3 文件
压缩包链接:
> [8.4-daily-speech-exercises.zip](https://1000h.org/public/jupyter-notebooks/8.4-daily-speech-exercises.zip)