-
Notifications
You must be signed in to change notification settings - Fork 245
#1142 で提案している解説ドキュメントの作成 #1216
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
Open
nmori
wants to merge
5
commits into
VOICEVOX:master
Choose a base branch
from
nmori:#1142_SingAPI解説ドキュメント
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
The head ref may contain hidden characters: "#1142_SingAPI\u89E3\u8AAC\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8"
Open
#1142 で提案している解説ドキュメントの作成 #1216
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
48bee85
#1142 で提案している解説ドキュメント作成
nmori 3b93106
ドキュメント内の構成順を整理しました
nmori a6d91f5
Merge branch 'master' into #1142_SingAPI解説ドキュメント
Hiroshiba 4e0506b
レビュー結果の反映
nmori 62b0a2c
Merge branch '#1142_SingAPI解説ドキュメント' of https://github.com/nmori/voic…
nmori File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| # ソングAPIの使い方 | ||
|
|
||
| VOICEVOX v0.16より、APIをつかって歌を歌うことができる様になりました。 | ||
|
|
||
| ## 例題とする楽譜 | ||
|
|
||
|  | ||
|
|
||
| ## APIの送信例 | ||
|
|
||
| ``` bash | ||
| echo -n '{ | ||
| "notes": [ | ||
| { "key": null, "frame_length": 15, "lyric": "" }, | ||
| { "key": 60, "frame_length": 45, "lyric": "ド" }, | ||
| { "key": 62, "frame_length": 45, "lyric": "レ" }, | ||
| { "key": 64, "frame_length": 45, "lyric": "ミ" }, | ||
| { "key": null, "frame_length": 15, "lyric": "" } | ||
| ] | ||
| }' > score.json | ||
|
|
||
| curl -s \ | ||
| -H "Content-Type: application/json" \ | ||
| -X POST \ | ||
| -d @score.json \ | ||
| "127.0.0.1:50021/sing_frame_audio_query?speaker=6000" \ | ||
| > query.json | ||
|
|
||
| curl -s \ | ||
| -H "Content-Type: application/json" \ | ||
| -X POST \ | ||
| -d @query.json \ | ||
| "127.0.0.1:50021/frame_synthesis?speaker=3001" \ | ||
| > audio.wav | ||
| ``` | ||
|
|
||
| ## 基礎的な考え方 | ||
|
|
||
| 歌声を生成するには、指示値を計算するために必要な「前提となるパラメータ」をAPIを用いて取得する必要があります。 | ||
|
|
||
| ### 1.アクセスポイントの取得 | ||
|
|
||
| APIのアクセスポイントをさがします。一般的には ``http://localhost:50021/``あたりになりますが、正しい数値は情報ファイルである ```C:\Users\(ユーザ名)\AppData\Roaming\voicevox\runtime-info.json```を参照することで得られます。 | ||
|
|
||
| ``` json | ||
| { | ||
| "formatVersion":X, | ||
| "appVersion":"0.XX.X", | ||
| "engineInfos":[ | ||
| { | ||
| "uuid":"00000000-0000-0000-00000-000000000000","url":"http://127.0.0.1:50021","name":"VOICEVOX Engine" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| このURLと表記されているURLがアクセスポイントになります。 | ||
|
|
||
| ### 2. 歌声の指定 | ||
|
|
||
| VOICEVOXでは、歌い方と声を分けて生成しています。その指定をするためには ``http://localhost:50021/singers``にアクセスして、歌声リストを手にいれます。 | ||
|
|
||
| ``` json | ||
| [ | ||
| { | ||
| "name": "波音リツ", | ||
| "speaker_uuid": "00000000-0000-0000-0000-000000000000", | ||
| "styles": [ | ||
| { | ||
| "name": "クイーン", | ||
| "id": 3065, | ||
| "type": "frame_decode" | ||
| }, | ||
| { | ||
| "name": "ノーマル", | ||
| "id": 6000, | ||
| "type": "sing" | ||
| } | ||
| ], | ||
| "version": "0.15.3" | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| 歌い方を指定するためにつかえるIDとしては、typeが``sing``になっているもののみです。(ほかのIDを指定すると生成時エラーとなるため注意してください) | ||
nmori marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 歌い方(クエリデータ)から歌声に変えるときには、typeが``frame_decode``となっているものを指定できます。 | ||
nmori marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ここでは、歌い方を指定するIDは``6000``、歌声は``3065``と仮定して説明を進めます。 | ||
|
|
||
| ### 3. 計算に必要な数値の取得 | ||
|
|
||
| 楽譜データを歌声にかえるためには、楽譜を内部の計算値に変換したJSONを用意する必要があります。そのために必要な係数を取得します。係数は``http://localhost:50021/engine_manifest``で取得できます。 | ||
|
|
||
| ```JSON | ||
nmori marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "default_sampling_rate": 24000, | ||
| "frame_rate": 93.75, | ||
| ``` | ||
|
|
||
| この ``frame_rate``が計算に必要な値となります。 | ||
|
|
||
| ### 4. 楽譜用JSONデータの作成 | ||
|
|
||
| 楽譜用のJSONデータは下記のようなフォーマットになります。 | ||
|
|
||
| ``` json | ||
| { | ||
| "notes": [ | ||
| { "key": null, "frame_length": 15, "lyric": "" }, | ||
| { "key": 60, "frame_length": 45, "lyric": "ド" }, | ||
| { "key": 62, "frame_length": 45, "lyric": "レ" }, | ||
| { "key": 64, "frame_length": 45, "lyric": "ミ" }, | ||
| { "key": null, "frame_length": 15, "lyric": "" } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| 音程は ``key``、発音長は ``frame_length``、発話語は ``leric`` で指定することになります。 | ||
|
|
||
| #### 4.1 フレーム長の考え方 | ||
|
|
||
| frame_lengthはこのように計算します。 | ||
|
|
||
|  | ||
|
|
||
| テンポが125bpm であるとき、4分音符は ``60秒あたり 125 回叩かれるリズム``ということになります。すなわち、``4分音符1回あたり0.48 秒``になります。 | ||
|
|
||
| フレーム長の数字は、``frame_rate`` に時間をかけたものになりますので、4分音符1つ分の時間で歌わせるためには、``0.48 ✕ 93.75 = 45.0`` となります。 | ||
|
|
||
| この数字は小数点のついた数字になりますが、VOICEVOX二指定するときには四捨五入した整数値で指示するようにしてください。 | ||
nmori marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| #### 4.2 その他の値の決め方 | ||
|
|
||
| key は 音の高さ(MIDIノートナンバー)になります。真ん中のドの音が 60 となります。nullが指定された場合は無音になります。 | ||
|
|
||
| lyricは発話語になります。カタカナで1語入れます。nullが指定された場合は無音になります。 | ||
nmori marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### 5. クエリの生成 | ||
|
|
||
| 楽譜データを歌い方データ(クエリデータ)に変換するには、``http://localhost:50021/sing_frame_audio_query`` にアクセスします。 | ||
|
|
||
| 楽譜データはPOSTで送信してください。 curlが使える場合は、下記のようなコマンドで送信できます。speakerには手順2で取得したIDを指定します。 | ||
|
|
||
| ``` bash | ||
| curl -s \ | ||
| -H "Content-Type: application/json" \ | ||
| -X POST \ | ||
| -d @score.json \ | ||
| "127.0.0.1:50021/sing_frame_audio_query?speaker=6000" \ | ||
| > query.json | ||
| ``` | ||
|
|
||
nmori marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| うまく行けば、``query.json``ファイルが生成されます。 | ||
|
|
||
| ### 6. 歌声の生成 | ||
|
|
||
| 楽譜データを歌い方データ(クエリデータ)に変換するには、``http://localhost:50021/frame_synthesis`` にアクセスします。 | ||
|
|
||
| 先程の``query.json``(クエリデータ)の中身をPOSTで送信してください。 curlが使える場合は、下記のようなコマンドで送信できます。speakerには手順2で取得した歌わせたい声のIDを指定します。 | ||
|
|
||
| ``` bash | ||
| curl -s \ | ||
| -H "Content-Type: application/json" \ | ||
| -X POST \ | ||
| -d @query.json \ | ||
| "127.0.0.1:50021/frame_synthesis?speaker=3065" \ | ||
| > audio.wav | ||
| ``` | ||
|
|
||
| うまく行けば、``audio.wav``ファイルが生成されます | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.