08-22-1126, chapter 4.5-sentences finished.

This commit is contained in:
xiaolai
2024-08-22 11:26:55 +08:00
parent 73b23dbf63
commit 5cf7da3e04
13 changed files with 374 additions and 42 deletions

View File

@@ -0,0 +1,98 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"../audios/city-us-female.mp3 exists\n",
"../audios/network-us-female.mp3 exists\n",
"../audios/conversation-us-male.mp3 exists\n",
"../audios/sentence-opinions-vary-nova.mp3 exists\n",
"../audios/conversation-us-female.mp3 exists\n",
"../audios/goal-of.mp3 exists\n",
"../audios/sentence-it-done-nova.mp3 exists\n",
"../audios/comfort-us-female.mp3 exists\n",
"../audios/hotdog-us-female.mp3 exists\n",
"../audios/sentence-opinions-vary-alloy.mp3 exists\n",
"../audios/goal-of-3.mp3 exists\n",
"../audios/sentence-it-done-alloy.mp3 exists\n",
"../audios/She-will-cherish-those-memories-and-ever-hold-them-close-to-her-heart.-nova.mp3 exists\n",
"../audios/comfort-us-male.mp3 exists\n",
"../audios/goal-of-1.mp3 exists\n",
"../audios/hotdog-us-male.mp3 exists\n",
"../audios/She-will-cherish-those-memories-and-ever-hold-them-close-to-her-heart.-alloy.mp3 exists\n",
"../audios/goal-of-2.mp3 exists\n",
"../audios/goal-of-4.mp3 exists\n",
"../audios/network-us-male.mp3 exists\n",
"../audios/city-us-male.mp3 exists\n",
"61\n",
"['Go-away-us-male', 'Do-all-us-male', 'I-am-us-female', 'a-bad-day-us-female', 'Was-he-hurt-us-female', 'city-us-female', 'partner-us-female', 'interview-us-male', 'Go-away-us-female', 'network-us-female', 'Dont-you-us-female', 'conversation-us-male', 'Throw-it-us-male', 'It-was-your-job-us-female', 'sentence-opinions-vary-nova', 'conversation-us-female', 'goal-of', 'stem-from-us-female', 'Do-it-us-male', 'sentence-it-done-nova', 'hard-nosed-us-male', 'comfort-us-female', 'a-bad-day-us-male', 'with-this-us-female', 'partner-us-male', 'Do-it-us-female', 'hotdog-us-female', 'She-is-us-male', 'Miss-you-so-much-us-female', 'sentence-opinions-vary-alloy', 'interview-us-female', 'goal-of-3', 'sentence-it-done-alloy', 'She-will-cherish-those-memories-and-ever-hold-them-close-to-her-heart.-nova', 'at-that-time-us-female', 'hard-nosed-us-female', 'comfort-us-male', 'Throw-it-us-female', 'I-am-us-male', 'goal-of-1', 'Was-he-hurt-us-male', 'Do-all-us-female', 'Would-you-us-male', 'hotdog-us-male', 'She-is-us-female', 'It-was-your-job-us-male', 'stem-from-us-male', 'with-this-us-male', 'She-will-cherish-those-memories-and-ever-hold-them-close-to-her-heart.-alloy', 'at-that-time-us-male', 'He-is-us-female', 'Dont-you-us-male', 'They-are-us-male', 'goal-of-2', 'goal-of-4', 'network-us-male', 'They-are-us-female', 'He-is-us-male', 'Would-you-us-female', 'Miss-you-so-much-us-male', 'city-us-male']\n"
]
}
],
"source": [
"import os\n",
"\n",
"def readlines_from_file(filename):\n",
" with open(filename, 'r') as f:\n",
" return f.readlines()\n",
"\n",
"filename = \"../../sounds-of-american-english/4.4-linking.md\"\n",
"\n",
"lines = readlines_from_file(filename)\n",
"mp3_file_paths = []\n",
"for line in lines:\n",
" if \".mp3\" in line:\n",
" # extract all substring between 'audios/' and '.mp3'\n",
" # there may be more than one substring in a line\n",
" while 'audios/' in line:\n",
" start = line.index('audios/') + len('audios/')\n",
" end = line.index('.mp3')\n",
" mp3_file_paths.append(line[start:end])\n",
" line = line[end+4:]\n",
"# remove duplicates in mp3_file_paths\n",
"mp3_file_paths = list(set(mp3_file_paths))\n",
"\n",
"# copy f'../audios/us/{mp3_file_path}' to f'../audios/{mp3_file_path}' uisng os module\n",
"for mp3_file_path in mp3_file_paths:\n",
" # check if the file exists\n",
" if os.path.exists(f'../audios/{mp3_file_path}.mp3'):\n",
" print(f'../audios/{mp3_file_path}.mp3 exists')\n",
" else:\n",
" os.system(f'cp ../audios/us/{mp3_file_path}.mp3 ../audios/{mp3_file_path}.mp3')\n",
"\n",
" # print(f'cp ../audios/us/{mp3_file_path}.mp3 ../audios/{mp3_file_path}.mp3')\n",
"\n",
"\n",
"print(len(mp3_file_paths))\n",
"print(mp3_file_paths)\n"
]
}
],
"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.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}