Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function toPayload(): array
$voiceSettings = $providerOptions['voice_settings'] ?? [];

$supportedOptions = [
'model_id' => $providerOptions['model_id'] ?? null,
'model_id' => $providerOptions['model_id'] ?? ($this->request->model() !== '' ? $this->request->model() : null),
'voice_settings' => [
'stability' => $voiceSettings['stability'] ?? null,
'use_speaker_boost' => $voiceSettings['use_speaker_boost'] ?? null,
Expand Down
33 changes: 33 additions & 0 deletions tests/Providers/ElevenLabs/AudioTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,39 @@
});
});

it('sends the model given to using() as the model_id', function (): void {
FixtureResponse::fakeResponseSequence(
'text-to-speech/onwK4e9ZLuTAKqWW03F9',
'elevenlabs/text-to-speech-basic',
['Content-Type' => 'audio/wav']
);

Prism::audio()
->using('elevenlabs', 'eleven_flash_v2_5')
->withInput('Hello world!')
->withVoice('onwK4e9ZLuTAKqWW03F9')
->asAudio();

Http::assertSent(fn (Request $request): bool => $request->data()['model_id'] === 'eleven_flash_v2_5');
});

it('lets the model_id provider option win over the model given to using()', function (): void {
FixtureResponse::fakeResponseSequence(
'text-to-speech/onwK4e9ZLuTAKqWW03F9',
'elevenlabs/text-to-speech-basic',
['Content-Type' => 'audio/wav']
);

Prism::audio()
->using('elevenlabs', 'eleven_flash_v2_5')
->withInput('Hello world!')
->withVoice('onwK4e9ZLuTAKqWW03F9')
->withProviderOptions(['model_id' => 'eleven_multilingual_v2'])
->asAudio();

Http::assertSent(fn (Request $request): bool => $request->data()['model_id'] === 'eleven_multilingual_v2');
});

it('can generate audio with different response format', function (): void {
FixtureResponse::fakeResponseSequence(
'text-to-speech/onwK4e9ZLuTAKqWW03F9',
Expand Down