448 lines
35 KiB
Plaintext
448 lines
35 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "b94f103d-ac43-4d13-83cb-eb5090220881",
|
|
"metadata": {},
|
|
"source": [
|
|
"# EdgeTTS\n",
|
|
"\n",
|
|
"https://github.com/rany2/edge-tts\n",
|
|
"\n",
|
|
"edge-tts is a Python module that allows you to use Microsoft Edge's online text-to-speech service from within your Python code or using the provided edge-tts or edge-playback command."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "77deb08f-fec3-4327-b2f9-1c893aacaddc",
|
|
"metadata": {
|
|
"collapsed": true,
|
|
"jupyter": {
|
|
"outputs_hidden": true
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Requirement already satisfied: edge-tts in /opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages (6.1.10)\n",
|
|
"Requirement already satisfied: aiohttp>=3.8.0 in /opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages (from edge-tts) (3.9.3)\n",
|
|
"Requirement already satisfied: certifi>=2023.11.17 in /opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages (from edge-tts) (2024.2.2)\n",
|
|
"Requirement already satisfied: aiosignal>=1.1.2 in /opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages (from aiohttp>=3.8.0->edge-tts) (1.3.1)\n",
|
|
"Requirement already satisfied: attrs>=17.3.0 in /opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages (from aiohttp>=3.8.0->edge-tts) (23.2.0)\n",
|
|
"Requirement already satisfied: frozenlist>=1.1.1 in /opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages (from aiohttp>=3.8.0->edge-tts) (1.4.1)\n",
|
|
"Requirement already satisfied: multidict<7.0,>=4.5 in /opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages (from aiohttp>=3.8.0->edge-tts) (6.0.5)\n",
|
|
"Requirement already satisfied: yarl<2.0,>=1.0 in /opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages (from aiohttp>=3.8.0->edge-tts) (1.9.4)\n",
|
|
"Requirement already satisfied: idna>=2.0 in /opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages (from yarl<2.0,>=1.0->aiohttp>=3.8.0->edge-tts) (3.4)\n",
|
|
"Requirement already satisfied: pygame in /opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages (2.5.2)\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"%pip install edge-tts"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "2df59a42",
|
|
"metadata": {},
|
|
"source": [
|
|
"# English Voices\n",
|
|
"\n",
|
|
"* voice = \"en-US-GuyNeural\" (Male)\n",
|
|
"* voice = \"en-US-AnaNeural\" (Female)\n",
|
|
"* voice = \"en-US-AndrewNeural\" (Male)\n",
|
|
"* voice = \"en-US-AriaNeural\" (Female)\n",
|
|
"* voice = \"en-US-AvaNeural\" (Female)\n",
|
|
"* voice = \"en-US-BrianNeural\" (Male)\n",
|
|
"* voice = \"en-US-ChristopherNeural\" (Male)\n",
|
|
"* voice = \"en-US-EmmaNeural\" (Female)\n",
|
|
"* voice = \"en-US-EricNeural\" (Male)\n",
|
|
"* voice = \"en-US-GuyNeural\" (Male)\n",
|
|
"* voice = \"en-US-JennyNeural\" (Female)\n",
|
|
"* voice = \"en-US-MichelleNeural\" (Female)\n",
|
|
"* voice = \"en-US-RogerNeural\" (Male)\n",
|
|
"* voice = \"en-US-SteffanNeural\" (Male)\n",
|
|
"* voice = \"en-GB-LibbyNeural\" (Female)\n",
|
|
"* voice = \"en-GB-MaisieNeural\" (Female)\n",
|
|
"* voice = \"en-GB-RyanNeural\" (Male)\n",
|
|
"* voice = \"en-GB-SoniaNeural\" (Female)\n",
|
|
"* voice = \"en-GB-ThomasNeural\" (Male)\n",
|
|
"* voice = \"en-AU-NatashaNeural\" (Female)\n",
|
|
"* voice = \"en-AU-WilliamNeural\" (Male)\n",
|
|
"* voice = \"en-CA-ClaraNeural\" (Female)\n",
|
|
"* voice = \"en-CA-LiamNeural\" (Male)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"id": "71d35cd9",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"sun\n",
|
|
"../audios/sun-us-male.mp3 created\n",
|
|
"../audios/sun-us-female.mp3 created\n",
|
|
"../audios/sun-uk-male.mp3 created\n",
|
|
"../audios/sun-uk-female.mp3 created\n",
|
|
"\n",
|
|
"cup\n",
|
|
"../audios/cup-us-male.mp3 created\n",
|
|
"../audios/cup-us-female.mp3 created\n",
|
|
"../audios/cup-uk-male.mp3 created\n",
|
|
"../audios/cup-uk-female.mp3 created\n",
|
|
"\n",
|
|
"but\n",
|
|
"../audios/but-us-male.mp3 created\n"
|
|
]
|
|
},
|
|
{
|
|
"ename": "CancelledError",
|
|
"evalue": "",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[0;31mCancelledError\u001b[0m Traceback (most recent call last)",
|
|
"Cell \u001b[0;32mIn[5], line 81\u001b[0m\n\u001b[1;32m 79\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(w) \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m0\u001b[39m:\n\u001b[1;32m 80\u001b[0m filename \u001b[38;5;241m=\u001b[39m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m../audios/\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mw\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m-\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mregions[i]\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m-\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mgenders[i]\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m.mp3\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[0;32m---> 81\u001b[0m \u001b[38;5;28;01mawait\u001b[39;00m generate_edge_tts_audio(w, filename, voice\u001b[38;5;241m=\u001b[39mvoice, verbose\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m, overwrite\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m, play\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n",
|
|
"Cell \u001b[0;32mIn[5], line 18\u001b[0m, in \u001b[0;36mgenerate_edge_tts_audio\u001b[0;34m(text, file_name, voice, style, verbose, play, overwrite)\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mfile_name\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m exists, skipping...\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 16\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m\n\u001b[0;32m---> 18\u001b[0m \u001b[38;5;28;01mawait\u001b[39;00m communicate\u001b[38;5;241m.\u001b[39msave(file_name)\n\u001b[1;32m 19\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m play:\n\u001b[1;32m 20\u001b[0m pygame\u001b[38;5;241m.\u001b[39mmixer\u001b[38;5;241m.\u001b[39minit()\n",
|
|
"File \u001b[0;32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/edge_tts/communicate.py:523\u001b[0m, in \u001b[0;36mCommunicate.save\u001b[0;34m(self, audio_fname, metadata_fname)\u001b[0m\n\u001b[1;32m 517\u001b[0m metadata: Union[TextIOWrapper, ContextManager[\u001b[38;5;28;01mNone\u001b[39;00m]] \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 518\u001b[0m \u001b[38;5;28mopen\u001b[39m(metadata_fname, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mw\u001b[39m\u001b[38;5;124m\"\u001b[39m, encoding\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mutf-8\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 519\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m metadata_fname \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 520\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m nullcontext()\n\u001b[1;32m 521\u001b[0m )\n\u001b[1;32m 522\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m metadata, \u001b[38;5;28mopen\u001b[39m(audio_fname, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mwb\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;28;01mas\u001b[39;00m audio:\n\u001b[0;32m--> 523\u001b[0m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mfor\u001b[39;00m message \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstream():\n\u001b[1;32m 524\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m message[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtype\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124maudio\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m 525\u001b[0m audio\u001b[38;5;241m.\u001b[39mwrite(message[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdata\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n",
|
|
"File \u001b[0;32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/edge_tts/communicate.py:506\u001b[0m, in \u001b[0;36mCommunicate.stream\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 504\u001b[0m \u001b[38;5;66;03m# Stream the audio and metadata from the service.\u001b[39;00m\n\u001b[1;32m 505\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstate[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpartial_text\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtexts:\n\u001b[0;32m--> 506\u001b[0m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mfor\u001b[39;00m message \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m__stream():\n\u001b[1;32m 507\u001b[0m \u001b[38;5;28;01myield\u001b[39;00m message\n",
|
|
"File \u001b[0;32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/edge_tts/communicate.py:365\u001b[0m, in \u001b[0;36mCommunicate.__stream\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 363\u001b[0m \u001b[38;5;66;03m# Create a new connection to the service.\u001b[39;00m\n\u001b[1;32m 364\u001b[0m ssl_ctx \u001b[38;5;241m=\u001b[39m ssl\u001b[38;5;241m.\u001b[39mcreate_default_context(cafile\u001b[38;5;241m=\u001b[39mcertifi\u001b[38;5;241m.\u001b[39mwhere())\n\u001b[0;32m--> 365\u001b[0m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mwith\u001b[39;00m aiohttp\u001b[38;5;241m.\u001b[39mClientSession(\n\u001b[1;32m 366\u001b[0m trust_env\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m,\n\u001b[1;32m 367\u001b[0m timeout\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msession_timeout,\n\u001b[1;32m 368\u001b[0m ) \u001b[38;5;28;01mas\u001b[39;00m session, session\u001b[38;5;241m.\u001b[39mws_connect(\n\u001b[1;32m 369\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mWSS_URL\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m&ConnectionId=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mconnect_id()\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 370\u001b[0m compress\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m15\u001b[39m,\n\u001b[1;32m 371\u001b[0m proxy\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mproxy,\n\u001b[1;32m 372\u001b[0m headers\u001b[38;5;241m=\u001b[39m{\n\u001b[1;32m 373\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mPragma\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mno-cache\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 374\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCache-Control\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mno-cache\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 375\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mOrigin\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mchrome-extension://jdiccldimpdaibmpdkjnbmckianbfold\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 376\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAccept-Encoding\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mgzip, deflate, br\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 377\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAccept-Language\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124men-US,en;q=0.9\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 378\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUser-Agent\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 379\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36 Edg/91.0.864.41\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 380\u001b[0m },\n\u001b[1;32m 381\u001b[0m ssl\u001b[38;5;241m=\u001b[39mssl_ctx,\n\u001b[1;32m 382\u001b[0m ) \u001b[38;5;28;01mas\u001b[39;00m websocket:\n\u001b[1;32m 383\u001b[0m \u001b[38;5;66;03m# Send the request to the service.\u001b[39;00m\n\u001b[1;32m 384\u001b[0m \u001b[38;5;28;01mawait\u001b[39;00m send_command_request()\n\u001b[1;32m 386\u001b[0m \u001b[38;5;66;03m# Send the SSML request to the service.\u001b[39;00m\n",
|
|
"File \u001b[0;32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/aiohttp/client.py:1197\u001b[0m, in \u001b[0;36m_BaseRequestContextManager.__aenter__\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 1196\u001b[0m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__aenter__\u001b[39m(\u001b[38;5;28mself\u001b[39m) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m _RetType:\n\u001b[0;32m-> 1197\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_resp \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_coro\n\u001b[1;32m 1198\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_resp\n",
|
|
"File \u001b[0;32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/aiohttp/client.py:835\u001b[0m, in \u001b[0;36mClientSession._ws_connect\u001b[0;34m(self, url, method, protocols, timeout, receive_timeout, autoclose, autoping, heartbeat, auth, origin, params, headers, proxy, proxy_auth, ssl, verify_ssl, fingerprint, ssl_context, proxy_headers, compress, max_msg_size)\u001b[0m\n\u001b[1;32m 832\u001b[0m ssl \u001b[38;5;241m=\u001b[39m _merge_ssl_params(ssl, verify_ssl, ssl_context, fingerprint)\n\u001b[1;32m 834\u001b[0m \u001b[38;5;66;03m# send request\u001b[39;00m\n\u001b[0;32m--> 835\u001b[0m resp \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mrequest(\n\u001b[1;32m 836\u001b[0m method,\n\u001b[1;32m 837\u001b[0m url,\n\u001b[1;32m 838\u001b[0m params\u001b[38;5;241m=\u001b[39mparams,\n\u001b[1;32m 839\u001b[0m headers\u001b[38;5;241m=\u001b[39mreal_headers,\n\u001b[1;32m 840\u001b[0m read_until_eof\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m,\n\u001b[1;32m 841\u001b[0m auth\u001b[38;5;241m=\u001b[39mauth,\n\u001b[1;32m 842\u001b[0m proxy\u001b[38;5;241m=\u001b[39mproxy,\n\u001b[1;32m 843\u001b[0m proxy_auth\u001b[38;5;241m=\u001b[39mproxy_auth,\n\u001b[1;32m 844\u001b[0m ssl\u001b[38;5;241m=\u001b[39mssl,\n\u001b[1;32m 845\u001b[0m proxy_headers\u001b[38;5;241m=\u001b[39mproxy_headers,\n\u001b[1;32m 846\u001b[0m )\n\u001b[1;32m 848\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 849\u001b[0m \u001b[38;5;66;03m# check handshake\u001b[39;00m\n\u001b[1;32m 850\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m resp\u001b[38;5;241m.\u001b[39mstatus \u001b[38;5;241m!=\u001b[39m \u001b[38;5;241m101\u001b[39m:\n",
|
|
"File \u001b[0;32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/aiohttp/client.py:581\u001b[0m, in \u001b[0;36mClientSession._request\u001b[0;34m(self, method, str_or_url, params, data, json, cookies, headers, skip_auto_headers, auth, allow_redirects, max_redirects, compress, chunked, expect100, raise_for_status, read_until_eof, proxy, proxy_auth, timeout, verify_ssl, fingerprint, ssl_context, ssl, server_hostname, proxy_headers, trace_request_ctx, read_bufsize, auto_decompress, max_line_size, max_field_size)\u001b[0m\n\u001b[1;32m 576\u001b[0m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mwith\u001b[39;00m ceil_timeout(\n\u001b[1;32m 577\u001b[0m real_timeout\u001b[38;5;241m.\u001b[39mconnect,\n\u001b[1;32m 578\u001b[0m ceil_threshold\u001b[38;5;241m=\u001b[39mreal_timeout\u001b[38;5;241m.\u001b[39mceil_threshold,\n\u001b[1;32m 579\u001b[0m ):\n\u001b[1;32m 580\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_connector \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m--> 581\u001b[0m conn \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_connector\u001b[38;5;241m.\u001b[39mconnect(\n\u001b[1;32m 582\u001b[0m req, traces\u001b[38;5;241m=\u001b[39mtraces, timeout\u001b[38;5;241m=\u001b[39mreal_timeout\n\u001b[1;32m 583\u001b[0m )\n\u001b[1;32m 584\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m asyncio\u001b[38;5;241m.\u001b[39mTimeoutError \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[1;32m 585\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ServerTimeoutError(\n\u001b[1;32m 586\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mConnection timeout \u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mto host \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mformat(url)\n\u001b[1;32m 587\u001b[0m ) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mexc\u001b[39;00m\n",
|
|
"File \u001b[0;32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/aiohttp/connector.py:544\u001b[0m, in \u001b[0;36mBaseConnector.connect\u001b[0;34m(self, req, traces, timeout)\u001b[0m\n\u001b[1;32m 541\u001b[0m \u001b[38;5;28;01mawait\u001b[39;00m trace\u001b[38;5;241m.\u001b[39msend_connection_create_start()\n\u001b[1;32m 543\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 544\u001b[0m proto \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_create_connection(req, traces, timeout)\n\u001b[1;32m 545\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_closed:\n\u001b[1;32m 546\u001b[0m proto\u001b[38;5;241m.\u001b[39mclose()\n",
|
|
"File \u001b[0;32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/aiohttp/connector.py:944\u001b[0m, in \u001b[0;36mTCPConnector._create_connection\u001b[0;34m(self, req, traces, timeout)\u001b[0m\n\u001b[1;32m 942\u001b[0m _, proto \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_create_proxy_connection(req, traces, timeout)\n\u001b[1;32m 943\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m--> 944\u001b[0m _, proto \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_create_direct_connection(req, traces, timeout)\n\u001b[1;32m 946\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m proto\n",
|
|
"File \u001b[0;32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/aiohttp/connector.py:1226\u001b[0m, in \u001b[0;36mTCPConnector._create_direct_connection\u001b[0;34m(self, req, traces, timeout, client_error)\u001b[0m\n\u001b[1;32m 1219\u001b[0m server_hostname \u001b[38;5;241m=\u001b[39m (\n\u001b[1;32m 1220\u001b[0m (req\u001b[38;5;241m.\u001b[39mserver_hostname \u001b[38;5;129;01mor\u001b[39;00m hinfo[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mhostname\u001b[39m\u001b[38;5;124m\"\u001b[39m])\u001b[38;5;241m.\u001b[39mrstrip(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 1221\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m sslcontext\n\u001b[1;32m 1222\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 1223\u001b[0m )\n\u001b[1;32m 1225\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 1226\u001b[0m transp, proto \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_wrap_create_connection(\n\u001b[1;32m 1227\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_factory,\n\u001b[1;32m 1228\u001b[0m host,\n\u001b[1;32m 1229\u001b[0m port,\n\u001b[1;32m 1230\u001b[0m timeout\u001b[38;5;241m=\u001b[39mtimeout,\n\u001b[1;32m 1231\u001b[0m ssl\u001b[38;5;241m=\u001b[39msslcontext,\n\u001b[1;32m 1232\u001b[0m family\u001b[38;5;241m=\u001b[39mhinfo[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfamily\u001b[39m\u001b[38;5;124m\"\u001b[39m],\n\u001b[1;32m 1233\u001b[0m proto\u001b[38;5;241m=\u001b[39mhinfo[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mproto\u001b[39m\u001b[38;5;124m\"\u001b[39m],\n\u001b[1;32m 1234\u001b[0m flags\u001b[38;5;241m=\u001b[39mhinfo[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mflags\u001b[39m\u001b[38;5;124m\"\u001b[39m],\n\u001b[1;32m 1235\u001b[0m server_hostname\u001b[38;5;241m=\u001b[39mserver_hostname,\n\u001b[1;32m 1236\u001b[0m local_addr\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_local_addr,\n\u001b[1;32m 1237\u001b[0m req\u001b[38;5;241m=\u001b[39mreq,\n\u001b[1;32m 1238\u001b[0m client_error\u001b[38;5;241m=\u001b[39mclient_error,\n\u001b[1;32m 1239\u001b[0m )\n\u001b[1;32m 1240\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m ClientConnectorError \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[1;32m 1241\u001b[0m last_exc \u001b[38;5;241m=\u001b[39m exc\n",
|
|
"File \u001b[0;32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/site-packages/aiohttp/connector.py:1025\u001b[0m, in \u001b[0;36mTCPConnector._wrap_create_connection\u001b[0;34m(self, req, timeout, client_error, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1021\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 1022\u001b[0m \u001b[38;5;28;01masync\u001b[39;00m \u001b[38;5;28;01mwith\u001b[39;00m ceil_timeout(\n\u001b[1;32m 1023\u001b[0m timeout\u001b[38;5;241m.\u001b[39msock_connect, ceil_threshold\u001b[38;5;241m=\u001b[39mtimeout\u001b[38;5;241m.\u001b[39mceil_threshold\n\u001b[1;32m 1024\u001b[0m ):\n\u001b[0;32m-> 1025\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_loop\u001b[38;5;241m.\u001b[39mcreate_connection(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[1;32m 1026\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m cert_errors \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[1;32m 1027\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ClientConnectorCertificateError(req\u001b[38;5;241m.\u001b[39mconnection_key, exc) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mexc\u001b[39;00m\n",
|
|
"File \u001b[0;32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/asyncio/base_events.py:1147\u001b[0m, in \u001b[0;36mBaseEventLoop.create_connection\u001b[0;34m(self, protocol_factory, host, port, ssl, family, proto, flags, sock, local_addr, server_hostname, ssl_handshake_timeout, ssl_shutdown_timeout, happy_eyeballs_delay, interleave, all_errors)\u001b[0m\n\u001b[1;32m 1137\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m sock\u001b[38;5;241m.\u001b[39mtype \u001b[38;5;241m!=\u001b[39m socket\u001b[38;5;241m.\u001b[39mSOCK_STREAM:\n\u001b[1;32m 1138\u001b[0m \u001b[38;5;66;03m# We allow AF_INET, AF_INET6, AF_UNIX as long as they\u001b[39;00m\n\u001b[1;32m 1139\u001b[0m \u001b[38;5;66;03m# are SOCK_STREAM.\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1142\u001b[0m \u001b[38;5;66;03m# Disallowing AF_UNIX in this method, breaks backwards\u001b[39;00m\n\u001b[1;32m 1143\u001b[0m \u001b[38;5;66;03m# compatibility.\u001b[39;00m\n\u001b[1;32m 1144\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[1;32m 1145\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mA Stream Socket was expected, got \u001b[39m\u001b[38;5;132;01m{\u001b[39;00msock\u001b[38;5;132;01m!r}\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m-> 1147\u001b[0m transport, protocol \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mawait\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_create_connection_transport(\n\u001b[1;32m 1148\u001b[0m sock, protocol_factory, ssl, server_hostname,\n\u001b[1;32m 1149\u001b[0m ssl_handshake_timeout\u001b[38;5;241m=\u001b[39mssl_handshake_timeout,\n\u001b[1;32m 1150\u001b[0m ssl_shutdown_timeout\u001b[38;5;241m=\u001b[39mssl_shutdown_timeout)\n\u001b[1;32m 1151\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_debug:\n\u001b[1;32m 1152\u001b[0m \u001b[38;5;66;03m# Get the socket from the transport because SSL transport closes\u001b[39;00m\n\u001b[1;32m 1153\u001b[0m \u001b[38;5;66;03m# the old socket and creates a new SSL socket\u001b[39;00m\n\u001b[1;32m 1154\u001b[0m sock \u001b[38;5;241m=\u001b[39m transport\u001b[38;5;241m.\u001b[39mget_extra_info(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124msocket\u001b[39m\u001b[38;5;124m'\u001b[39m)\n",
|
|
"File \u001b[0;32m/opt/homebrew/Caskroom/miniconda/base/lib/python3.12/asyncio/base_events.py:1180\u001b[0m, in \u001b[0;36mBaseEventLoop._create_connection_transport\u001b[0;34m(self, sock, protocol_factory, ssl, server_hostname, server_side, ssl_handshake_timeout, ssl_shutdown_timeout)\u001b[0m\n\u001b[1;32m 1177\u001b[0m transport \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_make_socket_transport(sock, protocol, waiter)\n\u001b[1;32m 1179\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 1180\u001b[0m \u001b[38;5;28;01mawait\u001b[39;00m waiter\n\u001b[1;32m 1181\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m:\n\u001b[1;32m 1182\u001b[0m transport\u001b[38;5;241m.\u001b[39mclose()\n",
|
|
"\u001b[0;31mCancelledError\u001b[0m: "
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import edge_tts\n",
|
|
"import os\n",
|
|
"import pygame\n",
|
|
"import time\n",
|
|
"\n",
|
|
"async def generate_edge_tts_audio(text, file_name, voice='en-US-GuyNeural', style='newscast-formal', verbose=False, play=False, overwrite=False):\n",
|
|
" communicate = edge_tts.Communicate(text, voice)\n",
|
|
" # whether file exists?\n",
|
|
" if os.path.exists(file_name):\n",
|
|
" if overwrite:\n",
|
|
" if verbose:\n",
|
|
" print(f'{file_name} exists, overwriting...')\n",
|
|
" else:\n",
|
|
" if verbose:\n",
|
|
" print(f'{file_name} exists, skipping...')\n",
|
|
" return\n",
|
|
" \n",
|
|
" await communicate.save(file_name)\n",
|
|
" if play:\n",
|
|
" pygame.mixer.init()\n",
|
|
" pygame.mixer.music.load(file_name)\n",
|
|
" pygame.mixer.music.play()\n",
|
|
" if verbose:\n",
|
|
" print(f'{file_name} created')\n",
|
|
" \n",
|
|
" time.sleep(1.5)\n",
|
|
"\n",
|
|
"\n",
|
|
"\n",
|
|
"voices = [\"en-US-GuyNeural\", \"en-US-AriaNeural\", \"en-GB-RyanNeural\", \"en-GB-LibbyNeural\"]\n",
|
|
"regions = ['us', 'us', 'uk', 'uk']\n",
|
|
"genders = ['male', 'female', 'male', 'female']\n",
|
|
"\n",
|
|
"# only_us = False\n",
|
|
"only_us = True\n",
|
|
"if only_us:\n",
|
|
" voices = voices[:2]\n",
|
|
" print(voices)\n",
|
|
"\n",
|
|
"words = \"\"\"\n",
|
|
"sun,\n",
|
|
"cup,\n",
|
|
"but,\n",
|
|
"son,\n",
|
|
"comfort,\n",
|
|
"money,\n",
|
|
"young,\n",
|
|
"double,\n",
|
|
"country,\n",
|
|
"blood,\n",
|
|
"flood,\n",
|
|
"father,\n",
|
|
"watch,\n",
|
|
"wasp,\n",
|
|
"almond,\n",
|
|
"balm,\n",
|
|
"palm,\n",
|
|
"because,\n",
|
|
"clause,\n",
|
|
"paunch,\n",
|
|
"drawn,\n",
|
|
"awning,\n",
|
|
"law,\n",
|
|
"hot,\n",
|
|
"dog,\n",
|
|
"log,\n",
|
|
"bought,\n",
|
|
"thought,\n",
|
|
"fought,\n",
|
|
"car,\n",
|
|
"far,\n",
|
|
"start,\n",
|
|
"\"\"\"\n",
|
|
"\n",
|
|
"for word in words.strip().split(','):\n",
|
|
" print(word)\n",
|
|
" 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",
|
|
" await generate_edge_tts_audio(w, filename, voice=voice, verbose=True, overwrite=True, play=True)\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "862f0948",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"pygame.mixer.init()\n",
|
|
"pygame.mixer.music.load(OUTPUT_FILE)\n",
|
|
"pygame.mixer.music.play()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"id": "00939422-fbf9-4842-b82a-b6106624c075",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Files created!\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"#American\n",
|
|
"\n",
|
|
"import asyncio\n",
|
|
"import edge_tts\n",
|
|
"import pygame\n",
|
|
"\n",
|
|
"TEXT = \"hands\"\n",
|
|
"Wordlist = TEXT.split(\",\")\n",
|
|
"\n",
|
|
"for w in Wordlist:\n",
|
|
" # for VOICE in ['en-US-GuyNeural', 'en-US-JennyNeural', 'en-GB-RyanNeural', 'en-GB-SoniaNeural']:\n",
|
|
" for VOICE in ['en-US-GuyNeural', 'en-US-MichelleNeural']:\n",
|
|
" w = w.strip()\n",
|
|
" # OUTPUT_FILE = f\"{w}-{VOICE.replace('EricNeural', 'Guy-Male').replace('JennyNeural', 'Jenny-Female').replace('RyanNeural', 'Ryan-Male').replace('SoniaNeural', 'Sonia-Female').lower()}.mp3\"\n",
|
|
" OUTPUT_FILE = f\"{w}-{VOICE.replace('EricNeural', 'Male').replace('MichelleNeural', 'Female').replace('en-', '').lower()}.mp3\"\n",
|
|
" communicate = edge_tts.Communicate(w, VOICE)\n",
|
|
" await communicate.save(OUTPUT_FILE) \n",
|
|
"\n",
|
|
"print(\"Files created!\") "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "cecefa85-b37d-457e-9e99-e582dabdfb9f",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Files created!\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"#American Sentence\n",
|
|
"\n",
|
|
"import asyncio\n",
|
|
"import edge_tts\n",
|
|
"import pygame\n",
|
|
"\n",
|
|
"TEXT = \"cat,foot\"\n",
|
|
"Wordlist = TEXT.split(\",\")\n",
|
|
"\n",
|
|
"for w in Wordlist:\n",
|
|
" # for VOICE in ['en-US-GuyNeural', 'en-US-JennyNeural', 'en-GB-RyanNeural', 'en-GB-SoniaNeural']:\n",
|
|
" for VOICE in ['en-US-EricNeural', 'en-US-MichelleNeural']:\n",
|
|
" w = w.strip().replace(' ', '-')\n",
|
|
" # OUTPUT_FILE = f\"{w}-{VOICE.replace('EricNeural', 'Guy-Male').replace('JennyNeural', 'Jenny-Female').replace('RyanNeural', 'Ryan-Male').replace('SoniaNeural', 'Sonia-Female').lower()}.mp3\"\n",
|
|
" OUTPUT_FILE = f\"{w}-{VOICE.replace('EricNeural', 'Male').replace('MichelleNeural', 'Female').replace('en-', '').lower()}.mp3\"\n",
|
|
" communicate = edge_tts.Communicate(w, VOICE)\n",
|
|
" await communicate.save(OUTPUT_FILE) \n",
|
|
"\n",
|
|
"print(\"Files created!\") "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "93f68a91-7e6b-45ef-932e-533b695e4ac1",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# ru-RU-DmitryNeural\n",
|
|
"# ko-KR-InJoonNeural"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 51,
|
|
"id": "474c3f39-11ed-4d0a-b039-63df8b270044",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Files created!\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# British\n",
|
|
"\n",
|
|
"import asyncio\n",
|
|
"import edge_tts\n",
|
|
"import pygame\n",
|
|
"\n",
|
|
"TEXT = \"speak, student, school, frustrate\"\n",
|
|
"Wordlist = TEXT.split(\",\")\n",
|
|
"\n",
|
|
"for w in Wordlist:\n",
|
|
" # for VOICE in ['en-US-GuyNeural', 'en-US-JennyNeural', 'en-GB-RyanNeural', 'en-GB-SoniaNeural']:\n",
|
|
" for VOICE in ['en-GB-RyanNeural', 'en-GB-SoniaNeural']:\n",
|
|
" w = w.strip()\n",
|
|
" # OUTPUT_FILE = f\"{w}-{VOICE.replace('EricNeural', 'Guy-Male').replace('JennyNeural', 'Jenny-Female').replace('RyanNeural', 'Ryan-Male').replace('SoniaNeural', 'Sonia-Female').lower()}.mp3\"\n",
|
|
" OUTPUT_FILE = f\"{w}-{VOICE.replace('RyanNeural', 'Male').replace('SoniaNeural', 'Female').replace('en-GB-', 'uk-').lower()}.mp3\"\n",
|
|
" communicate = edge_tts.Communicate(w, VOICE)\n",
|
|
" await communicate.save(OUTPUT_FILE) \n",
|
|
"\n",
|
|
"print(\"Files created!\") "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 49,
|
|
"id": "42ecfe3f-f3ac-4fb7-92d0-795d51972051",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Files created!\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"#Korean\n",
|
|
"\n",
|
|
"import asyncio\n",
|
|
"import edge_tts\n",
|
|
"import pygame\n",
|
|
"\n",
|
|
"TEXT = \"photo, video\"\n",
|
|
"Wordlist = TEXT.split(\",\")\n",
|
|
"\n",
|
|
"for w in Wordlist:\n",
|
|
" # for VOICE in ['en-US-GuyNeural', 'en-US-JennyNeural', 'en-GB-RyanNeural', 'en-GB-SoniaNeural']:\n",
|
|
" for VOICE in ['ko-KR-InJoonNeural']:\n",
|
|
" w = w.strip()\n",
|
|
" # OUTPUT_FILE = f\"{w}-{VOICE.replace('EricNeural', 'Guy-Male').replace('JennyNeural', 'Jenny-Female').replace('RyanNeural', 'Ryan-Male').replace('SoniaNeural', 'Sonia-Female').lower()}.mp3\"\n",
|
|
" OUTPUT_FILE = f\"{w}-{VOICE.replace('InJoonNeural', 'kr').replace('SoniaNeural', 'Female').replace('ko-KR', 'ko').lower()}.mp3\"\n",
|
|
" communicate = edge_tts.Communicate(w, VOICE)\n",
|
|
" await communicate.save(OUTPUT_FILE) \n",
|
|
"\n",
|
|
"print(\"Files created!\") "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 55,
|
|
"id": "95b12e63-f92d-49b4-bd51-a2b9d059fd52",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Files created!\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"#Chinese\n",
|
|
"\n",
|
|
"import asyncio\n",
|
|
"import edge_tts\n",
|
|
"import pygame\n",
|
|
"\n",
|
|
"TEXT = \"room\"\n",
|
|
"Wordlist = TEXT.split(\",\")\n",
|
|
"\n",
|
|
"for w in Wordlist:\n",
|
|
" # for VOICE in ['en-US-GuyNeural', 'en-US-JennyNeural', 'en-GB-RyanNeural', 'en-GB-SoniaNeural']:\n",
|
|
" for VOICE in ['zh-CN-liaoning-XiaobeiNeural']:\n",
|
|
" w = w.strip()\n",
|
|
" # OUTPUT_FILE = f\"{w}-{VOICE.replace('EricNeural', 'Guy-Male').replace('JennyNeural', 'Jenny-Female').replace('RyanNeural', 'Ryan-Male').replace('SoniaNeural', 'Sonia-Female').lower()}.mp3\"\n",
|
|
" OUTPUT_FILE = f\"{w}-{VOICE.replace('liaoning-XiaobeiNeural', 'zh').replace('SoniaNeural', 'Female').replace('zh-CN', 'cn').lower()}.mp3\"\n",
|
|
" communicate = edge_tts.Communicate(w, VOICE)\n",
|
|
" await communicate.save(OUTPUT_FILE) \n",
|
|
"\n",
|
|
"print(\"Files created!\") "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "2128587f-e6c8-488d-8c40-6c958b9c735e",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"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": 5
|
|
}
|