엔진 API로 노래 부르게 하기
엔진 API 모드는 공식 VOICEVOX 엔진 호환의 송 엔드포인트도 제공합니다.
사전 준비
노래 모델을 사용하기 위해 config/voicevox.php의 core.vvms에 s0.vvm이 포함되어 있는지 확인합니다 (기본값으로 포함됨).
VOICEVOX_CORE_PATH=/path/to/voicevox_core/
Laravel판 엔진 실행
php artisan serve --port=50513
노래 음성 생성
1. sing_frame_audio_query 생성
curl -s -X POST "http://127.0.0.1:50513/sing_frame_audio_query?speaker=6000" \
-H "Content-Type: application/json" \
-d '{
"notes": [
{"id": "a", "key": null, "frame_length": 15, "lyric": ""},
{"id": "b", "key": 60, "frame_length": 94, "lyric": "ド"},
{"id": "c", "key": 62, "frame_length": 94, "lyric": "レ"},
{"id": "d", "key": 64, "frame_length": 187, "lyric": "ミ"},
{"id": "e", "key": null, "frame_length": 2, "lyric": ""}
]
}' \
> frame_audio_query.json
speaker에는 sing 또는 singing_teacher 종별의 스타일 ID (예: 6000)를 지정합니다.
2. frame_synthesis로 음성 합성
curl -s -X POST "http://127.0.0.1:50513/frame_synthesis?speaker=3001" \
-H "Content-Type: application/json" \
-d @frame_audio_query.json \
> song.wav
speaker에는 sing 또는 frame_decode 종별의 스타일 ID (예: 3001)를 지정합니다.
Laravel 클라이언트에서 사용
Laravel판 엔진을 향해 Voicevox::song()을 이용할 수 있습니다.
// config/voicevox.php
'client' => [
'url' => env('VOICEVOX_URL', 'http://127.0.0.1:50513'),
],
use Revolution\Voicevox\Song\Note;
use Revolution\Voicevox\Song\Score;
use Revolution\Voicevox\Voicevox;
$score = Score::make([
Note::make(length: 15),
Note::make(length: Note::len(480, 120), lyric: 'ド', key: 60),
Note::make(length: Note::len(480, 120), lyric: 'レ', key: 62),
Note::make(length: Note::len(960, 120), lyric: 'ミ', key: 64),
Note::make(length: 2),
]);
$response = Voicevox::song($score, teacher: 6000)->generate(id: 3001);
$response->storeAs('engine', 'song.wav');
F0·볼륨 조정 엔드포인트
curl -s -X POST "http://127.0.0.1:50513/sing_frame_f0?speaker=6000" \
-H "Content-Type: application/json" \
-d '{"score": {...}, "frame_audio_query": {...}}' \
> f0.json
curl -s -X POST "http://127.0.0.1:50513/sing_frame_volume?speaker=6000" \
-H "Content-Type: application/json" \
-d '{"score": {...}, "frame_audio_query": {...}}' \
> volume.json
F0와 볼륨을 개별적으로 업데이트할 경우 반드시 F0 → 볼륨 순서로 실행하세요.
송 관련 대응 현황
| 엔드포인트 | Laravel판 | 폴백 | 비고 |
|---|
POST /sing_frame_audio_query | ✅ | ✅ | |
POST /frame_synthesis | ✅ | ✅ | |
POST /sing_frame_f0 | ✅ | ✅ | |
POST /sing_frame_volume | ✅ | ✅ | f0 → volume 순으로 업데이트 |
GET /singers | ✅ | ✅ | |
GET /singer_info | ✅ | ✅ | 리소스 설치 필요 |
다음에 읽어볼 페이지
Score와 Note 상세
Song API에서 사용하는 Score / Note의 상세를 확인합니다.
엔진 API: 토크
텍스트 음성 합성 엔드포인트의 사용법을 확인합니다.
클라이언트: 송
같은 악보를 공식 엔진으로 직접 보내는 모드를 확인합니다.