Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jupyter notebookの例を追加 #510

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
236 changes: 236 additions & 0 deletions example/jupyter/voicevox.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "9dac395d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[33mWARNING: The directory '/home/jovyan/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.\u001b[0m\u001b[33m\n",
"\u001b[0mCollecting voicevox-core==0.14.3+cpu\n",
" Downloading https://github.com/VOICEVOX/voicevox_core/releases/download/0.14.3/voicevox_core-0.14.3+cpu-cp38-abi3-linux_x86_64.whl (815.6 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m815.6/815.6 MB\u001b[0m \u001b[31m3.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:05\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: numpy in /opt/conda/lib/python3.10/site-packages (from voicevox-core==0.14.3+cpu) (1.24.3)\n",
"Collecting pydantic<2,>=1.9.2 (from voicevox-core==0.14.3+cpu)\n",
" Downloading pydantic-1.10.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.1/3.1 MB\u001b[0m \u001b[31m3.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: typing-extensions>=4.2.0 in /opt/conda/lib/python3.10/site-packages (from pydantic<2,>=1.9.2->voicevox-core==0.14.3+cpu) (4.6.2)\n",
"Installing collected packages: pydantic, voicevox-core\n",
"Successfully installed pydantic-1.10.8 voicevox-core-0.14.3+cpu\n",
"\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
"\u001b[0m"
]
}
],
"source": [
"!pip install https://github.com/VOICEVOX/voicevox_core/releases/download/0.14.3/voicevox_core-0.14.3+cpu-cp38-abi3-linux_x86_64.whl"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "89495b1a",
"metadata": {},
"outputs": [
{
"ename": "ImportError",
"evalue": "libonnxruntime.so.1.13.1: cannot open shared object file: No such file or directory",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[2], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mvoicevox_core\u001b[39;00m\n",
"File \u001b[0;32m/opt/conda/lib/python3.10/site-packages/voicevox_core/__init__.py:11\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m _load_dlls \u001b[38;5;66;03m# noqa: F401\u001b[39;00m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01m_models\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m ( \u001b[38;5;66;03m# noqa: F401\u001b[39;00m\n\u001b[1;32m 4\u001b[0m AccelerationMode,\n\u001b[1;32m 5\u001b[0m AccentPhrase,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 9\u001b[0m SupportedDevices,\n\u001b[1;32m 10\u001b[0m )\n\u001b[0;32m---> 11\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01m_rust\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m METAS, SUPPORTED_DEVICES, VoicevoxCore \u001b[38;5;66;03m# noqa: F401\u001b[39;00m\n\u001b[1;32m 14\u001b[0m __all__ \u001b[38;5;241m=\u001b[39m [\n\u001b[1;32m 15\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mMETAS\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 16\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSUPPORTED_DEVICES\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 23\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mVoicevoxCore\u001b[39m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 24\u001b[0m ]\n",
"\u001b[0;31mImportError\u001b[0m: libonnxruntime.so.1.13.1: cannot open shared object file: No such file or directory"
]
}
],
"source": [
"import voicevox_core"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "d5d96fc8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"--2023-05-30 04:45:08-- https://github.com/VOICEVOX/voicevox_core/releases/download/0.14.3/download-linux-x64\n",
"Resolving github.com (github.com)... ::ffff:20.27.177.113, 20.27.177.113\n",
"Connecting to github.com (github.com)|::ffff:20.27.177.113|:443... connected.\n",
"HTTP request sent, awaiting response... 302 Found\n",
"Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/401730442/ea831b31-c15c-42e5-8e9c-876a3cae4b86?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230530%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230530T044509Z&X-Amz-Expires=300&X-Amz-Signature=e0d6d4a4b0091f8e61a9c340691d61c1ae18b57fb7bccab41a39f1e801c768fb&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=401730442&response-content-disposition=attachment%3B%20filename%3Ddownload-linux-x64&response-content-type=application%2Foctet-stream [following]\n",
"--2023-05-30 04:45:09-- https://objects.githubusercontent.com/github-production-release-asset-2e65be/401730442/ea831b31-c15c-42e5-8e9c-876a3cae4b86?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230530%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230530T044509Z&X-Amz-Expires=300&X-Amz-Signature=e0d6d4a4b0091f8e61a9c340691d61c1ae18b57fb7bccab41a39f1e801c768fb&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=401730442&response-content-disposition=attachment%3B%20filename%3Ddownload-linux-x64&response-content-type=application%2Foctet-stream\n",
"Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.109.133, 185.199.110.133, 185.199.111.133, ...\n",
"Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.109.133|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 5070696 (4.8M) [application/octet-stream]\n",
"Saving to: ‘download-linux-x64’\n",
"\n",
"download-linux-x64 100%[===================>] 4.83M 2.74MB/s in 1.8s \n",
"\n",
"2023-05-30 04:45:11 (2.74 MB/s) - ‘download-linux-x64’ saved [5070696/5070696]\n",
"\n"
]
}
],
"source": [
"!wget https://github.com/VOICEVOX/voicevox_core/releases/download/0.14.3/download-linux-x64"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "3541ca63",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[32m INFO\u001b[0m 対象OS: linux\n",
"\u001b[32m INFO\u001b[0m 対象CPUアーキテクチャ: x64\n",
"\u001b[32m INFO\u001b[0m ダウンロードデバイスタイプ: cpu\n",
"\u001b[32m INFO\u001b[0m ダウンロードvoicevox_coreバージョン: 0.14.3\n",
"\u001b[2Kvoicevox_core-linux-x64-cpu-0.14.3.zip \n",
"\u001b[2K\u001b[1Avoicevox_core-linux-x64-cpu-0.14.3.zip \u001b[1A\n",
"\u001b[2K\u001b[1Avoicevox_core-linux-x64-cpu-0.14.3.zip \u001b[1A\n",
"\u001b[2K\u001b[1Avoicevox_core-linux-x64-cpu-0.14.3.zip 0B 0B/s 00:00:00 ░░░░░░░░░░░░░░░░░░░░ 0%\u001b[1A\n",
"\u001b[2K\u001b[1Avoicevox_core-linux-x64-cpu-0.14.3.zip 782.72 MiB 3.81 MiB/s 00:03:23 ███████████████████░ 100%\n",
"\u001b[2K\u001b[1Avoicevox_core-linux-x64-cpu-0.14.3.zip ⠂ Inflating... \u001b[1A\n",
"\u001b[2K\u001b[1Avoicevox_core-linux-x64-cpu-0.14.3.zip ⠐ Writing files...1A\n",
"\u001b[2K\u001b[1Avoicevox_core-linux-x64-cpu-0.14.3.zip Done! \u001b[1A\n",
"open_jtalk_dic_utf_8-1.11.tar.gz Done! \u001b[32m INFO\u001b[0m 全ての必要なファイルダウンロードが完了しました\n"
]
}
],
"source": [
"!chmod +x download-linux-x64\n",
"!./download-linux-x64 "
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "04e58d1d",
"metadata": {},
"outputs": [],
"source": [
"! echo voicevox_core > /etc/ld.so.conf.d/voicevox.conf\n",
"! ldconfig"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "11e5a73a",
"metadata": {},
"outputs": [],
"source": [
"import voicevox_core"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "09ccee76",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"voicevox_core._models.Meta"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"voicevox_core.Meta"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "023a9db1",
"metadata": {},
"outputs": [],
"source": [
"from voicevox_core import AccelerationMode, AudioQuery, VoicevoxCore\n",
"\n",
"acceleration_mode = \"AUTO\"\n",
"open_jtalk_dict_dir = \"./voicevox_core/open_jtalk_dic_utf_8-1.11\"\n",
"speaker_id = 0\n",
"text = \"この音声は、ボイスボックスを使用して、出力されています。\"\n",
"\n",
"core = VoicevoxCore(\n",
" acceleration_mode=acceleration_mode, open_jtalk_dict_dir=open_jtalk_dict_dir\n",
" )\n",
"\n",
"core.load_model(speaker_id)\n",
"audio_query = core.audio_query(text, speaker_id)\n",
"wav = core.synthesis(audio_query, speaker_id)\n"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "4552ba7c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"b'RIFF$r\\x03\\x00WAVEfmt \\x10\\x00\\x00\\x00\\x01\\x00\\x01\\x00\\xc0]...'"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"wav"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5504843b",
"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.10.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}