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
4 changes: 3 additions & 1 deletion backend/src/audios/audio_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ async def generate_music(index: int) -> str | None:
instance_dict, instance_value
)

endpoint = f"projects/{cfg.PROJECT_ID}/locations/global/publishers/google/models/lyria-002"
endpoint = f"projects/{cfg.PROJECT_ID}/locations/global/publishers/google/models/{request_dto.model.value}"
response = await asyncio.to_thread(
ai_client.predict,
endpoint=endpoint,
Expand Down Expand Up @@ -399,12 +399,14 @@ class AudioService:
GenerationModelEnum.GEMINI_2_5_FLASH_TTS,
GenerationModelEnum.GEMINI_2_5_FLASH_LITE_PREVIEW_TTS,
GenerationModelEnum.GEMINI_2_5_PRO_TTS,
GenerationModelEnum.GEMINI_3_1_FLASH_TTS_PREVIEW,
}
TTS_MODELS = {
GenerationModelEnum.CHIRP_3,
}
MUSIC_MODELS = {
GenerationModelEnum.LYRIA_002,
GenerationModelEnum.LYRIA_3_CLIP_PREVIEW,
}

def __init__(
Expand Down
2 changes: 2 additions & 0 deletions backend/src/audios/dto/create_audio_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ def validate_audio_model(
) -> GenerationModelEnum:
allowed_audio_models = {
GenerationModelEnum.LYRIA_002,
GenerationModelEnum.LYRIA_3_CLIP_PREVIEW,
GenerationModelEnum.CHIRP_3,
GenerationModelEnum.GEMINI_2_5_FLASH_TTS,
GenerationModelEnum.GEMINI_2_5_FLASH_LITE_PREVIEW_TTS,
GenerationModelEnum.GEMINI_2_5_PRO_TTS,
GenerationModelEnum.GEMINI_3_1_FLASH_TTS_PREVIEW,
}

if value not in allowed_audio_models:
Expand Down
2 changes: 2 additions & 0 deletions backend/src/common/base_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ class GenerationModelEnum(str, Enum):
VEO_3_QUALITY_PREVIEW = "veo-3.0-generate-preview"
# Audio-Specific Models
LYRIA_002 = "lyria-002"
LYRIA_3_CLIP_PREVIEW = "lyria-3-clip-preview"
CHIRP_3 = "chirp_3"
GEMINI_2_5_FLASH_TTS = "gemini-2.5-flash-tts"
GEMINI_2_5_FLASH_LITE_PREVIEW_TTS = "gemini-2.5-flash-lite-preview-tts"
GEMINI_2_5_PRO_TTS = "gemini-2.5-pro-tts"
GEMINI_3_1_FLASH_TTS_PREVIEW = "gemini-3.1-flash-tts-preview"

# Workbench Models
WORKBENCH_RENDER = "workbench-render"
Expand Down
31 changes: 31 additions & 0 deletions backend/tests/audios/test_audio_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,34 @@ def test_process_gemini_in_background_sync(
called_config.speech_config.voice_config.prebuilt_voice_config.voice_name
== "Aoede"
)


class TestCreateAudioDtoValidation:

def test_validate_new_audio_models(self):
lyria_dto = CreateAudioDto(
workspace_id=1,
prompt="Lyria 3 test prompt",
model=GenerationModelEnum.LYRIA_3_CLIP_PREVIEW,
sample_count=1,
)
assert lyria_dto.model == GenerationModelEnum.LYRIA_3_CLIP_PREVIEW

gemini_dto = CreateAudioDto(
workspace_id=1,
prompt="Gemini 3.1 TTS test prompt",
model=GenerationModelEnum.GEMINI_3_1_FLASH_TTS_PREVIEW,
language_code=LanguageEnum.EN_US,
voice_name=VoiceEnum.PUCK,
)
assert (
gemini_dto.model == GenerationModelEnum.GEMINI_3_1_FLASH_TTS_PREVIEW
)

def test_invalid_audio_model_raises_error(self):
with pytest.raises(ValueError, match="is not a valid audio model"):
CreateAudioDto(
workspace_id=1,
prompt="Invalid model test",
model=GenerationModelEnum.GEMINI_2_5_FLASH,
)
Comment on lines +302 to +308

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 **Enhance unit test coverage for new TTS models validation requirements:** Adding a validation test case to verify that missing `language_code` raises a `ValueError` for the newly added `GEMINI_3_1_FLASH_TTS_PREVIEW` TTS model. This ensures that the model-specific validation logic is thoroughly covered.
Suggested change
def test_invalid_audio_model_raises_error(self):
with pytest.raises(ValueError, match="is not a valid audio model"):
CreateAudioDto(
workspace_id=1,
prompt="Invalid model test",
model=GenerationModelEnum.GEMINI_2_5_FLASH,
)
def test_invalid_audio_model_raises_error(self):
with pytest.raises(ValueError, match="is not a valid audio model"):
CreateAudioDto(
workspace_id=1,
prompt="Invalid model test",
model=GenerationModelEnum.GEMINI_2_5_FLASH,
)
def test_new_tts_model_missing_language_raises_error(self):
with pytest.raises(ValueError, match="language_code is required"):
CreateAudioDto(
workspace_id=1,
prompt="Missing language code test",
model=GenerationModelEnum.GEMINI_3_1_FLASH_TTS_PREVIEW,
language_code=None,
)

34 changes: 34 additions & 0 deletions frontend/src/app/common/config/model-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,23 @@ export const MODEL_CONFIGS: GenerationModelConfig[] = [
supportsLanguage: false,
},
},
{
value: 'lyria-3-clip-preview',
viewValue: 'Lyria 3 clip',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 **Consistency in view values formatting:** The view value `'Lyria 3 clip'` uses a lowercase "clip". For consistency with other models listed in `MODEL_CONFIGS` (e.g., `'Gemini TTS 3.1 Flash'`), it would be better to capitalize "Clip".
Suggested change
viewValue: 'Lyria 3 clip',
viewValue: 'Lyria 3 Clip',

type: 'AUDIO',
icon: 'music_note',
capabilities: {
supportedModes: ['Text to Audio'],
maxReferenceImages: 0,
supportedAspectRatios: [],
supportedResolutions: [],
supportedDurations: [],
supportsSeed: true,
supportsNegativePrompt: true,
supportsVoice: false,
supportsLanguage: false,
},
},
{
value: 'gemini-2.5-flash-tts',
viewValue: 'Gemini TTS',
Expand All @@ -330,6 +347,23 @@ export const MODEL_CONFIGS: GenerationModelConfig[] = [
supportsNegativePrompt: false,
},
},
{
value: 'gemini-3.1-flash-tts-preview',
viewValue: 'Gemini TTS 3.1 Flash',
type: 'AUDIO',
icon: 'record_voice_over',
capabilities: {
supportedModes: ['Text to Audio'],
maxReferenceImages: 0,
supportedAspectRatios: [],
supportedResolutions: [],
supportedDurations: [],
supportsVoice: true,
supportsLanguage: true,
supportsSeed: false,
supportsNegativePrompt: false,
},
},
{
value: 'chirp_3',
viewValue: 'Chirp',
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/app/services/audio/audio.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ import {MediaItem} from '../../common/models/media-item.model';
export enum GenerationModelEnum {
// Music
LYRIA_002 = 'lyria-002',
LYRIA_3_CLIP_PREVIEW = 'lyria-3-clip-preview',

// Speech
CHIRP_3 = 'chirp_3',
GEMINI_2_5_FLASH_TTS = 'gemini-2.5-flash-tts',
GEMINI_2_5_FLASH_LITE_PREVIEW_TTS = 'gemini-2.5-flash-lite-preview-tts',
GEMINI_2_5_PRO_TTS = 'gemini-2.5-pro-tts',
GEMINI_3_1_FLASH_TTS_PREVIEW = 'gemini-3.1-flash-tts-preview',
}

// 2. Define the Generic Request DTO
Expand Down
Loading