08-19-0938, chapter 3.2.1, edge-tts

This commit is contained in:
xiaolai
2024-08-19 09:38:54 +08:00
parent 000494b283
commit 96f0145f2b
50 changed files with 1087 additions and 301 deletions

View File

@@ -29,10 +29,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"id": "71d35cd9",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['en-US-GuyNeural', 'en-US-AriaNeural']\n",
"big\n",
"../audios/big-stop-us-male.mp3 created\n",
"../audios/big-stop-us-female.mp3 created\n"
]
}
],
"source": [
"import edge_tts\n",
"import os\n",
@@ -74,25 +85,7 @@
" print(voices)\n",
"\n",
"words = \"\"\"\n",
"bed,\n",
"guess,\n",
"pet,\n",
"bread,\n",
"dead,\n",
"lead,\n",
"any,\n",
"many,\n",
"says,\n",
"again,\n",
"said,\n",
"friend,\n",
"apple,\n",
"cat,\n",
"glass,\n",
"calf,\n",
"half,\n",
"laugh,\n",
"draught,\n",
"big\n",
"\"\"\"\n",
"\n",
"for word in words.strip().split(','):\n",
@@ -100,7 +93,7 @@
" for i, voice in enumerate(voices):\n",
" w = word.strip().lower()\n",
" if len(w) > 0:\n",
" filename = f'../audios/{w}-{regions[i]}-{genders[i]}.mp3'\n",
" filename = f'../audios/{w}-stop-{regions[i]}-{genders[i]}.mp3'\n",
" await generate_edge_tts_audio(w, filename, voice=voice, verbose=True, overwrite=False, play=True)\n"
]
},

View File

@@ -0,0 +1,192 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"# get all md file name start wtih 3.2.\n",
"md_files = [f for f in os.listdir('.') if f.startswith('3.2.') and f.endswith('.md')]\n",
"for f in md_files:\n",
" # get string between 3.2. and -\n",
" order = f.split('3.2.')[1].split('-')[0]\n",
" new_name = f'3.2.{str(int(order)-1)}-{f.split(\"-\")[1]}'\n",
" # rename file\n",
" os.rename(f, new_name)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
" {\n",
" text: \"3.2.1. p/b\",\n",
" link: \"/sounds-of-american-english/3.2.1-pb\",\n",
" },\n",
" {\n",
" text: \"3.2.2. t/d\",\n",
" link: \"/sounds-of-american-english/3.2.2-td\",\n",
" },\n",
" {\n",
" text: \"3.2.3. k/g\",\n",
" link: \"/sounds-of-american-english/3.2.3-kg\",\n",
" },\n",
" {\n",
" text: \"3.2.4. f/v\",\n",
" link: \"/sounds-of-american-english/3.2.4-fv\",\n",
" },\n",
" {\n",
" text: \"3.2.5. s/z\",\n",
" link: \"/sounds-of-american-english/3.2.5-sz\",\n",
" },\n",
" {\n",
" text: \"3.2.6. θ/ð\",\n",
" link: \"/sounds-of-american-english/3.2.6-θð\",\n",
" },\n",
" {\n",
" text: \"3.2.7. ʃ/ʒ\",\n",
" link: \"/sounds-of-american-english/3.2.7-ʃʒ\",\n",
" },\n",
" {\n",
" text: \"3.2.8. h\",\n",
" link: \"/sounds-of-american-english/3.2.8-h\",\n",
" },\n",
" {\n",
" text: \"3.2.9. tʃ/dʒ\",\n",
" link: \"/sounds-of-american-english/3.2.9-tʃdʒ\",\n",
" },\n",
" {\n",
" text: \"3.2.10. tr/dr\",\n",
" link: \"/sounds-of-american-english/3.2.10-trdr\",\n",
" },\n",
" {\n",
" text: \"3.2.11. ts/dz\",\n",
" link: \"/sounds-of-american-english/3.2.11-tsdz\",\n",
" },\n",
" {\n",
" text: \"3.2.12. m, n, ŋ\",\n",
" link: \"/sounds-of-american-english/3.2.12-mnŋ\",\n",
" },\n",
" {\n",
" text: \"3.2.13. l, r\",\n",
" link: \"/sounds-of-american-english/3.2.13-lr\",\n",
" },\n",
" {\n",
" text: \"3.2.14. w, j\",\n",
" link: \"/sounds-of-american-english/3.2.14-wj\",\n",
" },\n",
" ]\n",
" },\n",
"\n"
]
}
],
"source": [
"text = \"\"\"\n",
" {\n",
" text: \"2.2.2. p/b\",\n",
" link: \"/sounds-of-american-english/2.2.2-pb\",\n",
" },\n",
" {\n",
" text: \"2.2.3. t/d\",\n",
" link: \"/sounds-of-american-english/2.2.3-td\",\n",
" },\n",
" {\n",
" text: \"2.2.4. k/g\",\n",
" link: \"/sounds-of-american-english/2.2.4-kg\",\n",
" },\n",
" {\n",
" text: \"2.2.5. f/v\",\n",
" link: \"/sounds-of-american-english/2.2.5-fv\",\n",
" },\n",
" {\n",
" text: \"2.2.6. s/z\",\n",
" link: \"/sounds-of-american-english/2.2.6-sz\",\n",
" },\n",
" {\n",
" text: \"2.2.7. θ/ð\",\n",
" link: \"/sounds-of-american-english/2.2.7-θð\",\n",
" },\n",
" {\n",
" text: \"2.2.8. ʃ/ʒ\",\n",
" link: \"/sounds-of-american-english/2.2.8-ʃʒ\",\n",
" },\n",
" {\n",
" text: \"2.2.9. h\",\n",
" link: \"/sounds-of-american-english/2.2.9-h\",\n",
" },\n",
" {\n",
" text: \"2.2.10. tʃ/dʒ\",\n",
" link: \"/sounds-of-american-english/2.2.10-tʃdʒ\",\n",
" },\n",
" {\n",
" text: \"2.2.11. tr/dr\",\n",
" link: \"/sounds-of-american-english/2.2.11-trdr\",\n",
" },\n",
" {\n",
" text: \"2.2.12. ts/dz\",\n",
" link: \"/sounds-of-american-english/2.2.12-tsdz\",\n",
" },\n",
" {\n",
" text: \"2.2.13. m, n, ŋ\",\n",
" link: \"/sounds-of-american-english/2.2.13-mnŋ\",\n",
" },\n",
" {\n",
" text: \"2.2.14. l, r\",\n",
" link: \"/sounds-of-american-english/2.2.14-lr\",\n",
" },\n",
" {\n",
" text: \"2.2.15. w, j\",\n",
" link: \"/sounds-of-american-english/2.2.15-wj\",\n",
" },\n",
" ]\n",
" },\n",
"\"\"\"\n",
"\n",
"lines = text.split('\\n')\n",
"for line in lines:\n",
" if \"2.2.\" in line:\n",
" order = line.split('2.2.')[1].split('.')[0]\n",
" if len(order) <= 2:\n",
" new_order = str(int(order)-1)\n",
" line = line.replace(f'2.2.{order}', f'2.2.{new_order}')\n",
" order = line.split('2.2.')[1].split('-')[0]\n",
" if len(order) <= 2:\n",
" new_order = str(int(order)-1)\n",
" line = line.replace(f'2.2.{order}', f'2.2.{new_order}')\n",
" line = line.replace('2.2.', '3.2.')\n",
" print(line) \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
}