메인 콘텐츠로 건너뛰기

네이티브 모드에서 노래 부르게 하기

네이티브 모드의 노래 합성에서는 PHP FFI로 VOICEVOX CORE를 직접 호출합니다. ScoreNote의 조립 방식은 클라이언트 모드와 공통입니다.

사전 준비

  1. 설치와 설정을 완료했을 것
  2. VOICEVOX Core for PHP를 셋업했을 것
  3. .envVOICEVOX_CORE_PATH를 설정했을 것
VOICEVOX_CORE_PATH=/path/to/voicevox_core/
노래 모델을 사용하려면 config/voicevox.phpcore.vvmss0.vvm이 포함되어 있는지 확인하세요.

ScoreNote 만들기

use Revolution\Voicevox\Song\Note;
use Revolution\Voicevox\Song\Score;

$score = Score::make([
    Note::make(length: 15),
    Note::make(length: Note::len(ticks: 480, bpm: 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),
]);

기본적인 사용법

use Revolution\Voicevox\Song\Note;
use Revolution\Voicevox\Song\Score;
use function Revolution\Voicevox\song;

$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 = song($score, teacher: 6000)
    ->generate(id: 3001);

$response->storeAs('native', 'song.wav');
같은 Score를 사용하면 클라이언트 모드와 네이티브 모드에서 공통 악보를 재사용할 수 있습니다.

tap()으로 F0와 볼륨 재동기화

네이티브 Song에서도 tap()이 유용합니다. SongAudioQuery를 조정한 뒤 그대로 generate()에 넘길 수 있습니다.
use Revolution\Voicevox\Song\SongAudioQuery;
use function Revolution\Voicevox\song;

$response = song($score, teacher: 6000)
    ->tap(function (SongAudioQuery $song) {
        $song->sync();
    })
    ->generate(id: 3001);
F0와 볼륨을 개별적으로 업데이트할 경우는 반드시 다음 순서로 실행합니다.
->tap(function (SongAudioQuery $song) {
    $song->updateF0();
    $song->updateVolume();
})

클라이언트 모드와의 차이

항목클라이언트 Song네이티브 Song
엔진 실행필요불필요
FFI불필요필요
API 진입점Voicevox::song()song()
Score / Note공통공통
FFI의 구조는 PHP FFI, 코어 라이브러리 단독 흐름은 VOICEVOX Core for PHP 사용법을 참조하세요.

다음에 읽어볼 페이지

Score와 Note 상세

Song 악보 데이터의 실용적인 관리 방법을 확인합니다.

클라이언트 Song

HTTP 클라이언트 버전과의 차이를 비교합니다.

VOICEVOX for Laravel 개요

각 모드와 관련 페이지를 함께 확인합니다.
마지막 수정일 2026년 7월 13일