08-21-2048, chapter 4.4-linking-complete
This commit is contained in:
@@ -29,19 +29,10 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 22,
|
||||
"id": "71d35cd9",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"pygame 2.6.0 (SDL 2.28.4, Python 3.12.2)\n",
|
||||
"Hello from the pygame community. https://www.pygame.org/contribute.html\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import edge_tts\n",
|
||||
"import os\n",
|
||||
@@ -73,7 +64,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 20,
|
||||
"id": "4146f92e",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -82,22 +73,9 @@
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"['en-US-GuyNeural', 'en-US-AriaNeural']\n",
|
||||
"apple\n",
|
||||
"../audios/apple-us-male.mp3 exists, skipping...\n",
|
||||
"../audios/apple-us-female.mp3 exists, skipping...\n",
|
||||
"\n",
|
||||
"impossible\n",
|
||||
"../audios/impossible-us-male.mp3 exists, skipping...\n",
|
||||
"../audios/impossible-us-female.mp3 exists, skipping...\n",
|
||||
"\n",
|
||||
"possible\n",
|
||||
"../audios/possible-us-male.mp3 created\n",
|
||||
"../audios/possible-us-female.mp3 created\n",
|
||||
"\n",
|
||||
"ichthyosaur\n",
|
||||
"../audios/ichthyosaur-us-male.mp3 created\n",
|
||||
"../audios/ichthyosaur-us-female.mp3 created\n",
|
||||
"\n"
|
||||
"network\n",
|
||||
"../audios/network-us-male.mp3 created\n",
|
||||
"../audios/network-us-female.mp3 created\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -114,11 +92,7 @@
|
||||
" print(voices)\n",
|
||||
"\n",
|
||||
"words = \"\"\"\n",
|
||||
"apple,\n",
|
||||
"impossible,\n",
|
||||
"possible,\n",
|
||||
"ichthyosaur,\n",
|
||||
"\n",
|
||||
"network\n",
|
||||
"\"\"\"\n",
|
||||
"\n",
|
||||
"for word in words.strip().split(','):\n",
|
||||
@@ -132,7 +106,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"execution_count": 21,
|
||||
"id": "2d46cde4",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -140,7 +114,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"a-woman--without-her--man-is-nothing_openai.mp3\n"
|
||||
"she-will-cherish-those-memories-and-ever-hold-them-close-to-her-heart_openai.mp3\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
@@ -160,7 +134,7 @@
|
||||
" ) as response:\n",
|
||||
" response.stream_to_file(path)\n",
|
||||
" \n",
|
||||
"sentence = \"A woman..., without her..., man is nothing.\"\n",
|
||||
"sentence = \"She will cherish those memories and ever hold them close to her heart.\"\n",
|
||||
"\n",
|
||||
"# remove all punctuation at the end of sentence,\n",
|
||||
"# replace all spaces and punctuations in the sentence with dash\n",
|
||||
@@ -286,6 +260,52 @@
|
||||
"* voice = \"en-CA-ClaraNeural\" (Female)\n",
|
||||
"* voice = \"en-CA-LiamNeural\" (Male)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 38,
|
||||
"id": "7350bdce",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"../audios/ten-cups-us-alloy.mp3\n",
|
||||
"../audios/ten-cups-us-female.mp3\n",
|
||||
"../audios/increase-us-alloy.mp3\n",
|
||||
"../audios/increase-us-female.mp3\n",
|
||||
"../audios/brown-gate-us-alloy.mp3\n",
|
||||
"../audios/brown-gate-us-female.mp3\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# generate sentences using edge-tts\n",
|
||||
"sentences = \"\"\"\n",
|
||||
"ten cups\n",
|
||||
"increase\n",
|
||||
"brown gate\n",
|
||||
"\"\"\"\n",
|
||||
"# split the sentences into lines\n",
|
||||
"sentences = [s for s in sentences.strip().split(\"\\n\") if s]\n",
|
||||
"for sentence in sentences:\n",
|
||||
" # get the first three worrds and replace the first with 'sentence', join them with '-'ArithmeticError\n",
|
||||
" # filename = f'../audios/sentence-{sentence.split(\" \")[1]}-{sentence.split(\" \")[2]}.mp3'\n",
|
||||
" # for voice in [\"en-US-GuyNeural\", \"en-US-AriaNeural\"]:\n",
|
||||
" for voice in [\"alloy\", \"nova\"]:\n",
|
||||
"\n",
|
||||
" filename = f'../audios/{sentence.rstrip(\",.!?\").replace(\"'\", \"\").replace(\" \", \"-\")}-us-{voice}.mp3'.replace(\"alloy\", \"male\").replace(\"nova\", \"female\")\n",
|
||||
" # filename = f'../audios/{sentence.rstrip(\",.!?\").replace(\"'\", \"\").replace(\" \", \"-\")}-us-{voice}.mp3'.replace(\"en-US-GuyNeural\", \"male\").replace(\"en-US-AriaNeural\", \"female\")\n",
|
||||
" print(filename)\n",
|
||||
" # await generate_edge_tts_audio(sentence, filename, voice=voice, verbose=True, overwrite=True, play=True)\n",
|
||||
" get_openai_tts_audio(sentence, filename, performer=voice)\n",
|
||||
" \n",
|
||||
" \n",
|
||||
"\n",
|
||||
" # get_openai_tts_audio(sentence, f'../audios/{sentence.replace(\" \", \"-\")}-alloy.mp3', performer='alloy')\n",
|
||||
" # get_openai_tts_audio(sentence, f'../audios/{sentence.replace(\" \", \"-\")}-nova.mp3', performer='nova')\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
||||
Reference in New Issue
Block a user