0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Coqui TTS を使って音声合成を試してみる

Posted at

はじめに

Coqui TTS を使って下記の3つの音声合成を試しました。

  • Text to Speech: テキストを音声に変換する
  • Voice Cloning: テキストを好きな音声に変換する
  • Voice Conversion: 音声を別の音声に変換する

実際に出力した音声ファイルは下記のサイトにまとめました。

使用した Dockerfile 等は github に置いてあります。

また、サンプルの音声ファイルには Hi-Fi-CAPTAIN1 を利用させて頂きました。

Coqui TTS とは?

Coqui TTS は、TTS 生成用のライブラリです。
「トレーニング済みのモデルを使った音声合成」や「トレーニング済みのモデルをファインチューニングするツール」(今回は不使用)が提供されています。
python の実行環境さえあれば、環境構築から音声合成までコマンドで完結する敷居の低さなので、誰でも簡単に音声合成で遊べます。

Coqui/TTS はメンテナンスが停止されており、上記の Fork 版で開発が続いています。

インストール方法

今回はトレーニング済みモデルを使った音声合成ですので、pip でインストールするだけです。

# 日本語を使用するので[ja]も追加
pip install coqui-tts[ja]

大量のライブラリがインストールされるため、venvDocker の使用を推奨します。

テキスト読み上げ(Text to Speech)

まずは基本という事で、テキスト読み上げを試してみます。
以下の tts コマンドを実行します。

# 多言語、複数話者モデルの xtts_v2 を使用
tts --model_name "tts_models/multilingual/multi-dataset/xtts_v2" \
    --text "びょうきでわなくてもけんこうしんだんをうけにいきます" \
    --language_idx "ja" \
    --speaker_idx "Kazuhiko Atallah" \
    --out_path /app/data/text_to_speech/xtts_v2.wav
# 単一言語、単一話者モデルの kokoro/tacotron2-DDC を使用
tts --model_name "tts_models/ja/kokoro/tacotron2-DDC" \
    --text "びょうきでわなくてもけんこうしんだんをうけにいきます" \
    --out_path /app/data/text_to_speech/tacotron2-DDC.wav
  • モデルは初回使用時に自動でダウンロードされます
  • xtts は初回ダウンロード時に規約の同意が求められます

実際に出力されたものはこちらです。

モデル 音声 イントネーション 安定性 備考
xtts_v2 試聴 そこそこ 安定 ギリギリ実用性あり
kokoro/tacotron2-DDC 試聴 そこそこ 安定 声が若干ノイズ交じり
bark2 試聴 不可 不安定 日本語では実用性皆無

使用可能なモデルの確認方法は?

tts --list_models で表示されるモデル一覧から 「tts_models」 と書いてあるモデルを選択します。日本語を利用する場合は language が 「multilingual」 か 「ja」 となっているモデルが使えます。

 tts --list_models

Name format: type/language/dataset/model
  1: tts_models/multilingual/multi-dataset/xtts_v2 # 多言語(日本語含む)の tts で使用可能
 ...
  5: tts_models/bg/cv/vits # ブルガリア語(?)の tts のみ使用可能
 ...
 41: tts_models/ja/kokoro/tacotron2-DDC # 日本語の tts のみ使用可能
 ...

Name format: type/language/dataset/model
  1: vocoder_models/universal/libri-tts/wavegrad # 今回は使わない
 ...

Name format: type/language/dataset/model
  1: voice_conversion_models/multilingual/vctk/freevc24 # 多言語の voice conversion で使用可能
 ...

言語及び話者の確認方法は?

xtts モデルのように選択したモデルが複数言語、複数話者に対応している事があります。
--list_speaker_idxs--list_language_idxsコマンドで確認します。

# 使用可能な言語を確認する
tts --model_name "tts_models/multilingual/multi-dataset/xtts_v2" --list_language_idxs
Available language ids: (Set --language_idx flag to one of these values to use the multi-lingual model.
['en', 'es', ... , 'ja', 'hi']

# 使用可能な話者を確認する
tts --model_name "tts_models/multilingual/multi-dataset/xtts_v2" --list_speaker_idxs
Available speaker ids: (Set --speaker_idx flag to one of these values to use the multi-speaker model.
['Claribel Dervla', 'Daisy Studious', ... , 'Luis Moray', 'Marcos Rudaski']

音声複製(Voice Cloning)

TTS と違い、テキストを好きな音声で読み上げます。
事前に好きな音声ファイルを用意し、以下の tts コマンドを実行します。

# 初回実行時
tts --model_name "tts_models/multilingual/multi-dataset/xtts_v2" \
    --text "びょうきでわなくてもけんこうしんだんをうけにいきます" \
    --language_idx "ja" \
    --speaker_wav data/desc/*.wav \
    --speaker_idx "hi-fi-captain-ja-woman" \
    --out_path /app/data/voice_cloning/xtts_v2_1.wav
# 2回目以降に同じ音声を使うなら speaker_idx を指定すればOK
tts --model_name "tts_models/multilingual/multi-dataset/xtts_v2" \
    --text "びょうきでわなくてもけんこうしんだんをうけにいきます" \
    --language_idx "ja" \
    --speaker_idx "hi-fi-captain-ja-woman" \
    --out_path /app/data/voice_cloning/xtts_v2_2.wav

Voice Cloning に対応しているモデルは下記の通りです(2025年10月現在)。

  • tts_models/multilingual/multi-dataset/xtts_v2
  • tts_models/multilingual/multi-dataset/xtts_v1.1
  • tts_models/multilingual/multi-dataset/your_tts
  • tts_models/multilingual/multi-dataset/bark
  • tts_models/en/multi-dataset/tortoise-v2

実際に出力されたものはこちらです。

モデル 音声 声質 安定性 備考
xtts_v2 試聴 若干似ている 安定 ギリギリ実用性がある
xtts_v1.1 視聴 ほぼ別人 不安定
(無音出力等)
イントネーションも不自然
bark2 視聴 別人 不安定
(ノイズのみ等)
日本語では実用性皆無

音声変換(Voice Conversion)

音声変換は2つの機能と違い、既にある音声ファイルを別の音声に変換します。
事前に好きな音声ファイルを用意し、以下の tts コマンドを実行します。

# 音声変換の実行
tts --model_name voice_conversion_models/multilingual/multi-dataset/openvoice_v2 \
    --source_wav /app/data/src/Seikatsu01_C-U__000100.wav \
    --target_wav /app/data/dest/*.wav \
    --out_path /app/data/voice_conversion/openvoice_v2.wav

Voice Conversion に対応しているモデルは下記の通りです(2025年10月現在)。

  • voice_conversion_models/multilingual/vctk/freevc24
  • voice_conversion_models/multilingual/multi-dataset/knnvc
  • voice_conversion_models/multilingual/multi-dataset/openvoice_v1
  • voice_conversion_models/multilingual/multi-dataset/openvoice_v2

実際に出力されたものはこちらです。

モデル 音声 声質 安定性 備考
freevc24 試聴 ほぼ別人 安定 イントネーションが外人
knnvc 試聴 若干似てる 安定 籠った音質になる
openvoice_v1 試聴 別人 安定 変換元と変換先を足して2で割ったような声質になる
openvoice_v2 試聴 似てる 安定 実用性あり

感想

Text to Speech についてはイントネーションが物足りず、使い勝手はイマイチな印象を受けました。 Voice Cloning も同様にイントネーションに問題があるので、実用性はなさそうです。 VOICEVOX をはじめとした高品質かつフリーな読み上げソフトがある昨今は余計に逆風です。

ただ、 Voice Conversionopenvoice_v2 は思った以上に綺麗に変換出来ていて驚きました。が、悪いこと以外に用途が思い浮かばないですね…。

  1. Okamoto, T., Shiga, Y., & Kawai, H. (2023). Hi-Fi-CAPTAIN: High-fidelity and high-capacity conversational speech synthesis corpus developed by NICT. 2 3 4

  2. Bark は元々音楽生成を目的とした Suno-AI モデルをベースにしているため、挙動が安定しない 2

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?