【たった10分】アプリにもずんだもんを組み込める!PythonでVOICEVOXを使う方法を解説|キャラクターや設定変更方法も【ずんだもん解説】
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
📢 VOICEVOXとPythonを使った音声合成の方法
ShamakuroがVOICEVOXとPythonを使って高品質な音声を合成する方法を紹介します。VOICEVOXは無料で高品質な声を合成できるツールで、特にZundamonというキャラクターの声が有名です。通常はアプリのインターフェースで操作されますが、PythonからVOICEVOXを実行し、テキストを入力して音声を再生する方法を学ぶことができます。VOICEVOXを起動し、HTTPサーバーを介して音声合成エンジンを操作し、テキストから音声を合成し、再生するという4つのステップを説明します。VOICEVOXをインストールし、起動することでローカルにHTTPサーバーが動作し、Pythonからリクエストを送信して音声合成を実行します。
🔍 VOICEVOXのキャラクターと音声設定の確認
まず、Pythonのrequestsライブラリを使ってVOICEVOXのHTTPサーバーにアクセスし、利用可能なキャラクターのリストを取得します。richライブラリを用いてデータを整形し、読みやすく表示します。キャラクターの各声はユニークなIDが割り当てられており、後に使用するためにメモしておくべきです。次に、VOICEVOXの声を再生するプログラムを紹介します。プログラムはVOICEVOXのHTTPサーバーのホストとポートを指定し、キャラクターの声のタイプをIDで指定します。テキストを入力し、音声合成のためのクエリを作成し、VOICEVOXエンジンで音声を合成し、WAVE形式のデータを再生するという4つの機能を持つプログラムを実行します。
🎙️ PythonでVOICEVOXの音声合成を実行
VOICEVOXの音声合成エンジンをPythonから操作し、テキストを音声に変換する方法について説明します。作成したクエリデータを変更することで、話速やピッチ、プロソディなどの設定を調整できます。アプリのインターフェースに表示されるスライダー設定は、クエリ内の特定の設定に対応しています。例えば、話速を1.5倍にするには、プログラムにそのようなスニペットを追加します。この設定で同じテキストの音声合成を再生し、設定の変更による変化を確認できます。Shamakuroは、PythonでVOICEVOXを使用してテキストから音声を再生する方法を解説し、GitHubで紹介したサンプルプログラムを共有します。VOICEVOXをインストールすることなく、エンジンのみをダウンロードして同じ機能を実現することも可能です。
📘 Shamakuroチャンネルの紹介とおわりに
Shamakuroは、AIやPythonに関する知的好奇心を刺激するビデオを投稿しています。このビデオに興味を持ったら、高評価とチャンネル登録を検討してください。ビデオを最後まで視聴していただきありがとうございます。
Mindmap
Keywords
💡VOICEVOX
💡Python
💡HTTPサーバー
💡声合成
💡WAVEファイル
💡キャラクタータイプ
💡speaking speed
💡pitch
💡requestsライブラリ
💡richライブラリ
💡GitHub
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
Hello, this is Shamakuro.
In this video, I will explain how to use VOICEVOX with Python.
VOICEVOX is a tool that allows you to synthesize high-quality voices for free.
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.
Usually, VOICEVOX is operated on the app's interface after installation.
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.
You can perform actions like changing character types and adjusting speaking speed, just like on the app's interface.
It's very simple, so I hope you'll watch until the end.
Now, let me provide an overview of the content I'll be covering in this video.
First, I will explain the overall process of running VOICEVOX from Python.
For those who are more interested in the actual steps, you can skip ahead using the chapters.
The process of using VOICEVOX from Python consists of these four steps:
Launching VOICEVOX
Obtaining a query for voice synthesis
Synthesizing voice from the query
Playing back the synthesized voice
I'll explain each of these steps in detail.
First, install and launch VOICEVOX.
Although it may appear that only the app is running on the interface, an HTTP server is actually running locally at this point.
By sending requests to this HTTP server, you can execute the voice synthesis engine through a program.
In this case, I'm using Python, but any method that can send requests to the HTTP server will work.
Once VOICEVOX is launched, you need to input some text to obtain a query for voice synthesis.
While you can use the obtained query as-is for voice synthesis,
if you want to change settings like speaking speed or pitch, you'll need to modify the query data.
Next, you'll send a request for voice synthesis based on the obtained query.
This will result in a WAVE-format audio file being returned.
Finally, by playing this WAVE file using Python, you can output the voice of VOICEVOX based on the input text.
Understanding this overall process will make it easier to follow the explanations that follow.
With this understanding, let's proceed to the actual preparation!
First, since this is essential, let's install VOICEVOX.
Visit the official website and click on the "Download" button in the center of the screen.
I'll provide a link to the official VOICEVOX website in the description, so you can access it from there as well.
On the download page, select the appropriate options for your PC and click the "Download" button.
In my case, I'm choosing the mode that supports Windows OS with only CPU.
Once downloaded, run the installer and follow the on-screen instructions to install VOICEVOX.
At this point, you're ready to use VOICEVOX from Python by launching the VOICEVOX app.
Remember, the HTTP server is already up and running locally while the VOICEVOX app is running.
Let's confirm that the HTTP server is functioning properly as a last step.
Open a web browser and access the following URL:
If you see a document titled "VOICEVOX ENGINE," that confirms that VOICEVOX is functioning as an HTTP server.
From here on, I'll explain how to use VOICEVOX from a Python program.
First, let's start by accessing the server from Python to check the list of available characters.
We'll be using the requests library, so input the following command to install it.
Then, I've written a program that specifies the host and port of the HTTP server,
and accesses the /speakers endpoint to retrieve data.
This simple program just displays the returned data in JSON format on the terminal.
When you execute this program, you'll see the available character types and their voices in JSON format.
While the correct data is obtained, it might be a bit hard to read as is.
Let's improve this by importing the print method from the rich library and overwriting the existing print statement.
The rich library is highly effective and easy to introduce.
I've explained how to use it in past videos, so you might want to check those out as well.
With this, the readability of the data has improved thanks to the rich print results.
Looking at the obtained data, you'll notice that each character type is assigned an ID.
For example, the "Normal" voice of "Shikoku Metan" has an ID of "2," and the "Sweet" voice has an ID of "0."
These unique ID values are assigned to each voice type.
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.
Next, I'll introduce the actual program to input text and play back the VOICEVOX voice.
At the beginning of this program, I specify the host and port of VOICEVOX's HTTP server.
For the speaker value, I'll specify the ID of the character voice type that we checked earlier.
In this case, I'll use the "Normal" voice of "Zundamon," which has an ID of "3."
The rest of the program consists of four functions.
The first function creates a query for voice synthesis based on the provided text.
Using this query, we send a request to VOICEVOX to create the query.
The second function executes voice synthesis based on the query.
By providing the query returned from the first function as an argument, we use VOICEVOX's engine to synthesize the voice.
The third function is for playing back the voice synthesized by VOICEVOX.
By providing the WAVE-format data returned by the second function as an argument, we can play the voice.
The fourth function takes user input text, and in sequence, executes the three functions described above.
In the end, running the fourth function allows us to synthesize
and play back VOICEVOX's voice based on the user's input text.
Now, let's go ahead and run this program!
Now running...
The text entered could be read out loud.
By modifying the values in the created query, you can adjust settings like speaking speed, pitch, and prosody.
Let's take a look at the contents of the query_data variable to see what's inside.
Now running...
When you inspect the bottom of the returned JSON data, you'll find information about various settings within the query.
In this way, the slider-style settings displayed on the app's interface correspond to specific settings in the query.
For instance, if you want to increase the speaking speed to 1.5x, you can achieve that by adding a program snippet like this.
With this setup, let's play back the synthesized voice from the same text as before.
Now running...
As I changed the settings, the audio played back faster than before.
As you can see, it is easy to change the settings, so everyone is encouraged to try changing various settings!
In this video, I've explained how to use VOICEVOX from Python to play back voice from text.
I'll be sharing the two program files I introduced in this video as samples on my GitHub.
I'll provide a link in the description, so feel free to check them out if you're interested.
You can also change the speaking character and its settings or synthesize voices for multiple characters at once.
For further instructions, I encourage you to start VOICEVOX and refer to the official documentation.
Additionally, I wanted to show a comparison with the app interface this time, so I demonstrated a straightforward and conventional installation process.
However, you can actually achieve the same functionality without installing the app version; having just the VOICEVOX engine is sufficient.
You can download only the engine from the official GitHub repository,
so if you're looking to avoid on-screen interactions, this might be a viable option.
That's all from Shamakuro.
On this channel, I post videos that stimulate intellectual curiosity on topics like AI and Python.
If you found this video interesting, I'd be delighted if you could give it a thumbs up and subscribe to the channel!
Thank you for watching until the end!
Weitere ähnliche Videos ansehen
5.0 / 5 (0 votes)