Files
everyone-can-use-english/1000-hours/public/jupyter-notebooks/edge-tts-valcab-pronounciation.ipynb
an-lee dab09ea644 Package: add 1000-hours repo in workspace (#337)
* add 1000-hours repo in workspace

* update README
2024-02-20 15:40:18 +08:00

205 lines
5.4 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "b94f103d-ac43-4d13-83cb-eb5090220881",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"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": null,
"id": "77deb08f-fec3-4327-b2f9-1c893aacaddc",
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"!pip install edge-tts\n",
"!pip install pygame"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9aad6634-e833-4ec4-b285-84e051329712",
"metadata": {},
"outputs": [],
"source": [
"import asyncio\n",
"import edge_tts\n",
"import pygame\n",
"\n",
"TEXT = \"\"\"\n",
"happy\n",
"\"\"\"\n",
"\n",
"Wordlist = TEXT.split(\",\")\n",
"\n",
"for w in Wordlist:\n",
" for VOICE in ['en-US-GuyNeural', 'en-GB-RyanNeural']:\n",
" # for VOICE in ['en-US-GuyNeural']:\n",
" w = w.strip()\n",
" OUTPUT_FILE = f\"{w.replace(' ', '-').replace('?', '')}-{VOICE[3:5].replace('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": null,
"id": "1e54069c-db63-45ba-86e8-726730b19255",
"metadata": {},
"outputs": [],
"source": [
"import asyncio\n",
"import edge_tts\n",
"import pygame\n",
"\n",
"TEXT = \"happi\"\n",
"Wordlist = TEXT.split(\",\")\n",
"\n",
"for w in Wordlist:\n",
" for VOICE in ['zh-CN-YunxiNeural', 'zh-CN-XiaoxiaoNeural']:\n",
" w = w.strip()\n",
" OUTPUT_FILE = f\"{w}-{VOICE.replace('YunxiNeural', 'male').replace('XiaoxiaoNeural', 'female').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": "09d5ab47-5807-4ded-a8b9-45277831d425",
"metadata": {},
"outputs": [],
"source": [
"# 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\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": null,
"id": "00939422-fbf9-4842-b82a-b6106624c075",
"metadata": {},
"outputs": [],
"source": [
"import asyncio\n",
"import edge_tts\n",
"import pygame\n",
"\n",
"TEXT = \"goal\"\n",
"Wordlist = TEXT.split(\",\")\n",
"\n",
"for w in Wordlist:\n",
" for VOICE in ['ko-KR-InJoonNeural']:\n",
" w = w.strip()\n",
" OUTPUT_FILE = f\"{w}-{VOICE.replace('YunxiNeural', 'male').replace('XiaoxiaoNeural', 'female').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": null,
"id": "474c3f39-11ed-4d0a-b039-63df8b270044",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"print(os.getcwd())"
]
},
{
"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.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}