【たった10分】アプリにもずんだもんを組み込める!PythonでVOICEVOXを使う方法を解説|キャラクターや設定変更方法も【ずんだもん解説】

しゃまくろ
13 Aug 202310:41

Summary

TLDRこのビデオでは、無料で高品質な声を合成できるツール「VOICEVOX」をPythonから操作する方法を解説します。VOICEVOXはアプリのインターフェース上で操作されるが、PythonプログラムからVOICEVOXを実行し、テキストを元に声を再生する方法を学ぶことができます。VOICEVOXを起動し、HTTPサーバーを介して声合成エンジンを操作し、テキストをもとにWAVE形式の音声ファイルを生成し、再生する方法を紹介します。さらに、設定を変更して話速やピッチを調整する方法も紹介しています。

Takeaways

  • 🌟 VOICEVOXは無料で高品質な声を合成できるツールです。
  • 🎥 このビデオでは、PythonからVOICEVOXを実行し、テキストを元に声を再生する方法を説明します。
  • 🔧 VOICEVOXはアプリのインターフェースを通じて操作されるが、Pythonプログラムから実行することもできます。
  • 📈 VOICEVOXを起動するとローカルでHTTPサーバーが動作し、プログラムから音声合成エンジンを操作できます。
  • 📚 Pythonのrequestsライブラリを使ってVOICEVOXのHTTPサーバーにリクエストを送信して操作します。
  • 🔑 VOICEVOXのキャラクターには一意のIDが割り当てられており、音声合成の際に使用されます。
  • 📝 音声合成のためのクエリを作成し、VOICEVOXのエンジンにリクエストを送信して音声を合成します。
  • 🎶 Pythonを使ってWAVE形式の音声ファイルを再生し、VOICEVOXの音声を出力できます。
  • 🛠️ クエリの値を変更することで、話速やピッチ、プロソディなどの設定を調整できます。
  • 🔗 VOICEVOXの公式ウェブサイトやGitHubリポジトリからエンジンのみをダウンロードして使用することも可能です。
  • 📘 公式ドキュメントを参照することで、VOICEVOXの使い方をさらに深く理解できます。
  • 🎉 このビデオはAIやPythonに関する知的好奇心を刺激するシリーズの一部であり、チャンネル登録と高評価をお願いします。

Q & A

  • VOICEVOXは何で、どのようにして無料で高品質な声を合成することができるのですか?

    -VOICEVOXは高品質な声を合成するためのツールで、アプリのインターフェースを通じて操作されることが一般的ですが、Pythonプログラムから実行し、テキストをもとに声を再生することができます。

  • VOICEVOXをPythonから実行するためには、どのようなステップが必要ですか?

    -VOICEVOXをPythonから実行するためには、VOICEVOXの起動、音声合成のためのクエリの取得、クエリからの音声合成、そして合成された音声の再生の4つのステップが必要です。

  • VOICEVOXをインストールした後、どのようにしてローカルのHTTPサーバーが動作しているか確認できますか?

    -VOICEVOXを起動した後、ウェブブラウザで特定のURLにアクセスして、VOICEVOX ENGINEというタイトルのドキュメントが表示されるか確認できます。

  • PythonでVOICEVOXのHTTPサーバーにアクセスするにはどうしたらよいですか?

    -Pythonのrequestsライブラリを使って、VOICEVOXのHTTPサーバーのホストとポートを指定し、/speakersエンドポイントにアクセスすることで、利用可能なキャラクターのリストを取得できます。

  • VOICEVOXのキャラクターにはそれぞれ固有のIDが割り当てられているとありますが、それらのIDはどのようにして確認できますか?

    -VOICEVOXをPythonから実行し、/speakersエンドポイントから取得したJSONデータを参照することで、キャラクターのIDを確認できます。

  • VOICEVOXで音声合成を実行するプログラムを作成する際、どのような機能を備えるべきですか?

    -音声合成を実行するプログラムは、テキストからクエリを作成し、VOICEVOXに合成要求を送信し、合成されたWAVE形式の音声ファイルを再生する機能を備えるべきです。

  • VOICEVOXの音声合成の際に、話速やピッチなどの設定を変更するにはどうしたらできますか?

    -作成されたクエリの値を変更することで、話速やピッチ、プロソディなどの設定を調整できます。

  • VOICEVOXの音声合成結果を再生するには、どのようなPythonライブラリが必要ですか?

    -音声合成結果を再生するには、PythonのWAVE形式のファイルを扱うライブラリが必要ですが、具体的なライブラリはスクリプトによって異なります。

  • VOICEVOXのプログラムを実行する際に、どのようにしてユーザー入力を受け付けますか?

    -VOICEVOXのプログラムでは、ユーザー入力を受け付けるために、入力テキストを取得するための関数を実行し、そのテキストに基づいて音声合成と再生を行うことができます。

  • VOICEVOXの使用に関するサンプルプログラムはどこで入手できますか?

    -VOICEVOXの使用に関するサンプルプログラムは、作成者のGitHubで共有されています。動画の説明欄からリンクをたどればアクセスできます。

  • VOICEVOXをインストールすることなくエンジンのみをダウンロードすることはできますか?

    -はい、VOICEVOXのエンジンのみをダウンロードして使用することができます。公式のGitHubリポジトリからエンジンのみをダウンロードできます。

Outlines

00:00

📢 VOICEVOXとPythonを使った音声合成の方法

ShamakuroがVOICEVOXとPythonを使って高品質な音声を合成する方法を紹介します。VOICEVOXは無料で高品質な声を合成できるツールで、特にZundamonというキャラクターの声が有名です。通常はアプリのインターフェースで操作されますが、PythonからVOICEVOXを実行し、テキストを入力して音声を再生する方法を学ぶことができます。VOICEVOXを起動し、HTTPサーバーを介して音声合成エンジンを操作し、テキストから音声を合成し、再生するという4つのステップを説明します。VOICEVOXをインストールし、起動することでローカルにHTTPサーバーが動作し、Pythonからリクエストを送信して音声合成を実行します。

05:02

🔍 VOICEVOXのキャラクターと音声設定の確認

まず、Pythonのrequestsライブラリを使ってVOICEVOXのHTTPサーバーにアクセスし、利用可能なキャラクターのリストを取得します。richライブラリを用いてデータを整形し、読みやすく表示します。キャラクターの各声はユニークなIDが割り当てられており、後に使用するためにメモしておくべきです。次に、VOICEVOXの声を再生するプログラムを紹介します。プログラムはVOICEVOXのHTTPサーバーのホストとポートを指定し、キャラクターの声のタイプをIDで指定します。テキストを入力し、音声合成のためのクエリを作成し、VOICEVOXエンジンで音声を合成し、WAVE形式のデータを再生するという4つの機能を持つプログラムを実行します。

10:09

🎙️ PythonでVOICEVOXの音声合成を実行

VOICEVOXの音声合成エンジンをPythonから操作し、テキストを音声に変換する方法について説明します。作成したクエリデータを変更することで、話速やピッチ、プロソディなどの設定を調整できます。アプリのインターフェースに表示されるスライダー設定は、クエリ内の特定の設定に対応しています。例えば、話速を1.5倍にするには、プログラムにそのようなスニペットを追加します。この設定で同じテキストの音声合成を再生し、設定の変更による変化を確認できます。Shamakuroは、PythonでVOICEVOXを使用してテキストから音声を再生する方法を解説し、GitHubで紹介したサンプルプログラムを共有します。VOICEVOXをインストールすることなく、エンジンのみをダウンロードして同じ機能を実現することも可能です。

📘 Shamakuroチャンネルの紹介とおわりに

Shamakuroは、AIやPythonに関する知的好奇心を刺激するビデオを投稿しています。このビデオに興味を持ったら、高評価とチャンネル登録を検討してください。ビデオを最後まで視聴していただきありがとうございます。

Mindmap

Keywords

💡VOICEVOX

VOICEVOXは、高品質な声を無料で合成できるツールです。このビデオでは、VOICEVOXをPythonから実行し、テキストを元に声を合成して再生する方法が説明されています。VOICEVOXは、特にZundamonというキャラクターの独特な声で知られています。

💡Python

Pythonは、このビデオの主題に関連するプログラミング言語で、VOICEVOXの声合成エンジンを操作するために使用されています。Pythonのプログラムを通じて、VOICEVOXのHTTPサーバーにリクエストを送信し、テキストを声に変換することができます。

💡HTTPサーバー

VOICEVOXアプリが起動すると、ローカルでHTTPサーバーが実行され、VOICEVOXの声合成エンジンにリクエストを送信できるようになります。このサーバーは、VOICEVOXの操作をプログラムから行うための重要なコンポーネントです。

💡声合成

声合成とは、テキストを音声に変換するプロセスのことです。このビデオでは、VOICEVOXを用いて、Pythonから声合成を行い、テキストをもとに音声を生成する方法が紹介されています。

💡WAVEファイル

WAVEファイルは、音声データを保存するためのファイル形式です。ビデオでは、VOICEVOXの声合成エンジンによって生成されたWAVEファイルを使って、音声を再生する方法が説明されています。

💡キャラクタータイプ

VOICEVOXでは、異なるキャラクタータイプを選択して、異なる声のスタイルを表現できます。ビデオでは、キャラクタータイプのIDを使用して、特定の声を選択し、テキストをその声で合成するプロセスが紹介されています。

💡speaking speed

speaking speedは、音声の話す速さを制御する設定です。ビデオでは、VOICEVOXの声合成の際に、speaking speedを調整して、話す速さを変更する方法が説明されています。

💡pitch

pitchは、音声の高さを制御する設定で、VOICEVOXの声合成エンジンで使用されます。ビデオでは、音声のpitchを調整して、異なるトーンの声を生成する方法が紹介されています。

💡requestsライブラリ

requestsライブラリはPythonで使用されるHTTPリクエストを送信するためのライブラリです。ビデオでは、このライブラリを使ってVOICEVOXのHTTPサーバーにアクセスし、キャラクターのリストを取得する方法が説明されています。

💡richライブラリ

richライブラリは、Pythonで使用されるテキストをより読みやすい形式で表示するためのライブラリです。ビデオでは、richライブラリを使ってVOICEVOXから取得したデータを美化し、読みやすくする方法が紹介されています。

💡GitHub

GitHubは、ソフトウェア開発者がコードを共有し、プロジェクトを共同で開発するためのプラットフォームです。ビデオでは、GitHubにアップロードされたVOICEVOXのサンプルプログラムやドキュメントへのリンクが提供されており、詳細な情報やコードを確認することができると説明されています。

Highlights

VOICEVOXは無料で高品質な声を合成できるツールです。

VOICEVOXはPythonから実行し、テキストに基づいて声を再生することができます。

VOICEVOXを起動するとローカルのHTTPサーバーが動作し、プログラムから音声合成エンジンを実行できます。

VOICEVOXのインストール方法と、Windows OS用CPU版の選択について説明しています。

HTTPサーバーが正しく動作しているか確認する方法を学びます。

Pythonのrequestsライブラリを使ってVOICEVOXのサーバーにアクセスし、キャラクターのリストを取得します。

richライブラリを使って取得したデータをより読みやすく表示する方法を紹介しています。

VOICEVOXのキャラクタータイプにはユニークなIDが割り当てられています。

Pythonプログラムを使ってVOICEVOXの声を入力テキストに基づいて再生する方法を学びます。

VOICEVOXのHTTPサーバーのホストとポートを指定し、キャラクターの声の種類を設定します。

音声合成のためのクエリを作成し、VOICEVOXにリクエストを送信するプログラムの作り方です。

VOICEVOXのエンジンを使ってクエリに基づいて音声を合成する方法を説明しています。

合成されたVOICEVOXの音声をWAVEファイルで再生する方法を学びます。

ユーザー入力テキストに基づいて音声合成と再生を行うプログラムの実行方法です。

クエリの値を変更して、話速やピッチ、プロソディなどの設定を調整する方法を紹介しています。

VOICEVOXのPythonプログラムを使用して、テキストから音声を再生する方法を総まとめしています。

GitHubでVOICEVOXのPythonプログラムのサンプルを共有し、詳細な情報へのリンクを提供しています。

VOICEVOXのアプリバージョンをインストールせずにエンジンのみをダウンロードして使用する方法も提案しています。

このチャンネルでは、AIやPythonに関する知的好奇心を刺激するビデオを投稿しています。

Transcripts

play00:00

Hello, this is Shamakuro.

play00:02

In this video, I will explain how to use VOICEVOX with Python.

play00:07

VOICEVOX is a tool that allows you to synthesize high-quality voices for free.

play00:13

As you can see in this video you are currently watching, it is known for creating the distinctive voice of Zundamon, a well-known character.

play00:21

Usually, VOICEVOX is operated on the app's interface after installation.

play00:27

However, in this video, I will show you how to execute VOICEVOX from a Python program and play back synthesized voices based on input text.

play00:37

You can perform actions like changing character types and adjusting speaking speed, just like on the app's interface.

play00:44

It's very simple, so I hope you'll watch until the end.

play00:51

Now, let me provide an overview of the content I'll be covering in this video.

play00:56

First, I will explain the overall process of running VOICEVOX from Python.

play01:01

For those who are more interested in the actual steps, you can skip ahead using the chapters.

play01:08

The process of using VOICEVOX from Python consists of these four steps:

play01:13

Launching VOICEVOX

play01:15

Obtaining a query for voice synthesis

play01:18

Synthesizing voice from the query

play01:20

Playing back the synthesized voice

play01:22

I'll explain each of these steps in detail.

play01:25

First, install and launch VOICEVOX.

play01:29

Although it may appear that only the app is running on the interface, an HTTP server is actually running locally at this point.

play01:37

By sending requests to this HTTP server, you can execute the voice synthesis engine through a program.

play01:46

In this case, I'm using Python, but any method that can send requests to the HTTP server will work.

play01:53

Once VOICEVOX is launched, you need to input some text to obtain a query for voice synthesis.

play02:00

While you can use the obtained query as-is for voice synthesis,

play02:04

if you want to change settings like speaking speed or pitch, you'll need to modify the query data.

play02:10

Next, you'll send a request for voice synthesis based on the obtained query.

play02:15

This will result in a WAVE-format audio file being returned.

play02:19

Finally, by playing this WAVE file using Python, you can output the voice of VOICEVOX based on the input text.

play02:28

Understanding this overall process will make it easier to follow the explanations that follow.

play02:34

With this understanding, let's proceed to the actual preparation!

play02:41

First, since this is essential, let's install VOICEVOX.

play02:47

Visit the official website and click on the "Download" button in the center of the screen.

play02:53

I'll provide a link to the official VOICEVOX website in the description, so you can access it from there as well.

play03:00

On the download page, select the appropriate options for your PC and click the "Download" button.

play03:08

In my case, I'm choosing the mode that supports Windows OS with only CPU.

play03:14

Once downloaded, run the installer and follow the on-screen instructions to install VOICEVOX.

play03:26

At this point, you're ready to use VOICEVOX from Python by launching the VOICEVOX app.

play03:34

Remember, the HTTP server is already up and running locally while the VOICEVOX app is running.

play03:41

Let's confirm that the HTTP server is functioning properly as a last step.

play03:47

Open a web browser and access the following URL:

play03:51

If you see a document titled "VOICEVOX ENGINE," that confirms that VOICEVOX is functioning as an HTTP server.

play04:01

From here on, I'll explain how to use VOICEVOX from a Python program.

play04:07

First, let's start by accessing the server from Python to check the list of available characters.

play04:15

We'll be using the requests library, so input the following command to install it.

play04:21

Then, I've written a program that specifies the host and port of the HTTP server,

play04:26

and accesses the /speakers endpoint to retrieve data.

play04:31

This simple program just displays the returned data in JSON format on the terminal.

play04:37

When you execute this program, you'll see the available character types and their voices in JSON format.

play04:44

While the correct data is obtained, it might be a bit hard to read as is.

play04:50

Let's improve this by importing the print method from the rich library and overwriting the existing print statement.

play04:56

The rich library is highly effective and easy to introduce.

play05:02

I've explained how to use it in past videos, so you might want to check those out as well.

play05:08

With this, the readability of the data has improved thanks to the rich print results.

play05:13

Looking at the obtained data, you'll notice that each character type is assigned an ID.

play05:20

For example, the "Normal" voice of "Shikoku Metan" has an ID of "2," and the "Sweet" voice has an ID of "0."

play05:28

These unique ID values are assigned to each voice type.

play05:33

Since we'll use these IDs later, it's a good idea to take note of the ID of the voice you want to use.

play05:41

Next, I'll introduce the actual program to input text and play back the VOICEVOX voice.

play05:48

At the beginning of this program, I specify the host and port of VOICEVOX's HTTP server.

play05:54

For the speaker value, I'll specify the ID of the character voice type that we checked earlier.

play06:01

In this case, I'll use the "Normal" voice of "Zundamon," which has an ID of "3."

play06:06

The rest of the program consists of four functions.

play06:10

The first function creates a query for voice synthesis based on the provided text.

play06:15

Using this query, we send a request to VOICEVOX to create the query.

play06:22

The second function executes voice synthesis based on the query.

play06:27

By providing the query returned from the first function as an argument, we use VOICEVOX's engine to synthesize the voice.

play06:35

The third function is for playing back the voice synthesized by VOICEVOX.

play06:41

By providing the WAVE-format data returned by the second function as an argument, we can play the voice.

play06:49

The fourth function takes user input text, and in sequence, executes the three functions described above.

play06:56

In the end, running the fourth function allows us to synthesize

play07:00

and play back VOICEVOX's voice based on the user's input text.

play07:07

Now, let's go ahead and run this program!

play07:11

Now running...

play07:40

The text entered could be read out loud.

play07:45

By modifying the values in the created query, you can adjust settings like speaking speed, pitch, and prosody.

play07:53

Let's take a look at the contents of the query_data variable to see what's inside.

play07:57

Now running...

play08:26

When you inspect the bottom of the returned JSON data, you'll find information about various settings within the query.

play08:34

In this way, the slider-style settings displayed on the app's interface correspond to specific settings in the query.

play08:41

For instance, if you want to increase the speaking speed to 1.5x, you can achieve that by adding a program snippet like this.

play08:48

With this setup, let's play back the synthesized voice from the same text as before.

play08:54

Now running...

play09:07

As I changed the settings, the audio played back faster than before.

play09:12

As you can see, it is easy to change the settings, so everyone is encouraged to try changing various settings!

play09:19

In this video, I've explained how to use VOICEVOX from Python to play back voice from text.

play09:27

I'll be sharing the two program files I introduced in this video as samples on my GitHub.

play09:34

I'll provide a link in the description, so feel free to check them out if you're interested.

play09:39

You can also change the speaking character and its settings or synthesize voices for multiple characters at once.

play09:46

For further instructions, I encourage you to start VOICEVOX and refer to the official documentation.

play09:54

Additionally, I wanted to show a comparison with the app interface this time, so I demonstrated a straightforward and conventional installation process.

play10:01

However, you can actually achieve the same functionality without installing the app version; having just the VOICEVOX engine is sufficient.

play10:08

You can download only the engine from the official GitHub repository,

play10:14

so if you're looking to avoid on-screen interactions, this might be a viable option.

play10:20

That's all from Shamakuro.

play10:23

On this channel, I post videos that stimulate intellectual curiosity on topics like AI and Python.

play10:30

If you found this video interesting, I'd be delighted if you could give it a thumbs up and subscribe to the channel!

play10:36

Thank you for watching until the end!

Rate This

5.0 / 5 (0 votes)

相关标签
VOICEVOXPython声合成HTTPサーバーZundamonアプリ操作プログラミングAI技術テキスト読み上げGitHub
您是否需要英文摘要?