|
13 | 13 | # limitations under the License. |
14 | 14 | # |
15 | 15 |
|
16 | | -import base64 |
17 | | -import enum |
18 | 16 | import os |
| 17 | +import pathlib |
19 | 18 |
|
20 | 19 | from pydantic import BaseModel, ValidationError, Field, ConfigDict |
21 | 20 | from typing import Literal, List, Optional, Union, Set |
|
30 | 29 | from .. import pytest_helper |
31 | 30 | from enum import Enum |
32 | 31 |
|
33 | | -IMAGE_PNG_FILE_PATH = os.path.abspath( |
34 | | - os.path.join(os.path.dirname(__file__), '../data/google.png') |
35 | | -) |
36 | | - |
37 | 32 | GEMINI_FLASH_LATEST = 'gemini-2.5-flash' |
38 | 33 | GEMINI_FLASH_2_0 = 'gemini-2.0-flash-001' |
39 | 34 | GEMINI_FLASH_IMAGE_LATEST = 'gemini-2.5-flash-image' |
40 | 35 |
|
41 | | -with open(IMAGE_PNG_FILE_PATH, 'rb') as image_file: |
42 | | - image_bytes = image_file.read() |
| 36 | +IMAGE_PNG_FILE_PATH = pathlib.Path(__file__).parent / '../data/google.png' |
| 37 | +image_bytes = IMAGE_PNG_FILE_PATH.read_bytes() |
| 38 | + |
| 39 | +AUDIO_WAV_FILE_PATH = pathlib.Path(__file__).parent / '../data/voice_sample.wav' |
| 40 | +audio_bytes = AUDIO_WAV_FILE_PATH.read_bytes() |
| 41 | + |
43 | 42 |
|
44 | 43 | safety_settings_with_method = [ |
45 | 44 | { |
@@ -1964,6 +1963,27 @@ def test_schema_with_any_of(client): |
1964 | 1963 | assert 'type' in response.parsed['fruit'][0] |
1965 | 1964 |
|
1966 | 1965 |
|
| 1966 | +def test_replicated_voice_config(client): |
| 1967 | + with pytest_helper.exception_if_vertex(client, errors.ClientError): |
| 1968 | + client.models.generate_content( |
| 1969 | + model='gemini-2.5-flash-preview-tts-voice-replication-rev22-2025-10-28', |
| 1970 | + contents=t.t_contents( |
| 1971 | + 'Produce a speech response saying "Cheese"' |
| 1972 | + ), |
| 1973 | + config=types.GenerateContentConfig( |
| 1974 | + response_modalities=['audio'], |
| 1975 | + speech_config=types.SpeechConfig( |
| 1976 | + voice_config=types.VoiceConfig( |
| 1977 | + replicated_voice_config=types.ReplicatedVoiceConfig( |
| 1978 | + voice_sample_audio=audio_bytes, |
| 1979 | + mime_type='audio/wav', |
| 1980 | + ) |
| 1981 | + ) |
| 1982 | + ), |
| 1983 | + ), |
| 1984 | + ) |
| 1985 | + |
| 1986 | + |
1967 | 1987 | def test_json_schema_with_streaming(client): |
1968 | 1988 |
|
1969 | 1989 | response = client.models.generate_content_stream( |
|
0 commit comments