iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
👌

Running VOICEVOX Engine on Google Colab for Use with the Mac Editor

に公開

What is VOICEVOX

https://voicevox.hiroshiba.jp/

Motivation

VOICEVOX is architected to run speech synthesis on the local PC's GPU/CPU, but the GPU version does not support macOS. Therefore, compared to other platforms, it cannot fully utilize the machine's performance[1].

The overall structure of VOICEVOX is a three-tier architecture:

  1. A cross-platform Electron app (Editor)
  2. A Web API written in Python that calls the core (Engine)
  3. A core written in Rust

With this structure, it is possible (if you are willing to try) to separate layers 2 and 3.

Reference: https://github.com/VOICEVOX

I want to run layers 2 and 3 on Colab, change the connection destination of layer 1, and use the editor from macOS.

Disclaimer

Also, there are concerns such as:

  • When using an external proxy server, the input content is transmitted.
  • The published VOICEVOX engine API becomes accessible to the public.

Colab Code

  • T4 GPU
  • High-memory: Off

It worked smoothly with these runtime settings (upgrading to A100 or V100 will increase the synthesis speed).

import os

os.environ['ENGINE_VERSION'] = "0.15.0-preview.5"
!wget "https://github.com/VOICEVOX/voicevox_engine/releases/download/${ENGINE_VERSION}/voicevox_engine-linux-nvidia-${ENGINE_VERSION}.7z.001"
!7za x -y voicevox_engine-linux-nvidia-${ENGINE_VERSION}.7z.001

Tunnel Connection via Proxy

We will use ngrok to make port 50021 within the VM publicly accessible[2].

As long as the same thing can be achieved, you don't necessarily have to use ngrok; Cloudflare Tunnel might be a better option recently.

!pip install pyngrok
import os
import subprocess

from pyngrok import ngrok

# Start the engine
subprocess.Popen(["./linux-nvidia/run", "--use_gpu"])
port = 50021
public_url = ngrok.connect(port).public_url
print("VOICEVOX_API_BASE={}".format(public_url))

A temporary URL for the ngrok.io server will be displayed in the output like this.

VOICEVOX_API_BASE=https://XXXXXXXXXXXXXXX.ngrok.io

Building the VOICEVOX Editor

The connection destination for the VOICEVOX Editor is fixed to local in the build settings.[3]

Since we are changing the connection destination to the server running on Colab, we will build it ourselves.

git clone --depth 1 https://github.com/VOICEVOX/voicevox
cd voicevox
npm install

The settings are in .env.production, so we will modify them.

https://github.com/VOICEVOX/voicevox/blob/main/.env.production

Setting "executionEnabled": false, disables the command to run the local engine.

Replace the "host": "http://127.0.0.1:50021" part with your VOICEVOX_API_BASE URL and build.

npm run electron:build
open ./dist_electron/mac/VOICEVOX.app

How to Test

You can verify this by turning off your Mac's internet connection and checking if a connection error occurs in the VOICEVOX editor.

How to Close

Close the Colab notebook session to make the server inaccessible. At this point, the built VOICEVOX editor will no longer work.

脚注
  1. There is an issue for CoreML support: https://github.com/VOICEVOX/voicevox_core/issues/428 ↩︎

  2. https://saturncloud.io/blog/is-there-a-general-way-to-run-web-applications-on-google-colab/ ↩︎

  3. Issue regarding changing the API connection destination: https://github.com/VOICEVOX/voicevox/issues/220 ↩︎

Discussion