|
22 | 22 | from ._common import set_value_by_path as setv |
23 | 23 |
|
24 | 24 |
|
| 25 | +def _PrebuiltVoiceConfig_to_mldev( |
| 26 | + api_client: BaseApiClient, |
| 27 | + from_object: Union[dict[str, Any], object], |
| 28 | + parent_object: Optional[dict[str, Any]] = None, |
| 29 | +) -> dict[str, Any]: |
| 30 | + to_object: dict[str, Any] = {} |
| 31 | + if getv(from_object, ['voice_name']) is not None: |
| 32 | + setv(to_object, ['voiceName'], getv(from_object, ['voice_name'])) |
| 33 | + |
| 34 | + return to_object |
| 35 | + |
| 36 | + |
| 37 | +def _PrebuiltVoiceConfig_to_vertex( |
| 38 | + api_client: BaseApiClient, |
| 39 | + from_object: Union[dict[str, Any], object], |
| 40 | + parent_object: Optional[dict[str, Any]] = None, |
| 41 | +) -> dict[str, Any]: |
| 42 | + to_object: dict[str, Any] = {} |
| 43 | + if getv(from_object, ['voice_name']) is not None: |
| 44 | + setv(to_object, ['voiceName'], getv(from_object, ['voice_name'])) |
| 45 | + |
| 46 | + return to_object |
| 47 | + |
| 48 | + |
| 49 | +def _VoiceConfig_to_mldev( |
| 50 | + api_client: BaseApiClient, |
| 51 | + from_object: Union[dict[str, Any], object], |
| 52 | + parent_object: Optional[dict[str, Any]] = None, |
| 53 | +) -> dict[str, Any]: |
| 54 | + to_object: dict[str, Any] = {} |
| 55 | + if getv(from_object, ['prebuilt_voice_config']) is not None: |
| 56 | + setv( |
| 57 | + to_object, |
| 58 | + ['prebuiltVoiceConfig'], |
| 59 | + _PrebuiltVoiceConfig_to_mldev( |
| 60 | + api_client, getv(from_object, ['prebuilt_voice_config']), to_object |
| 61 | + ), |
| 62 | + ) |
| 63 | + |
| 64 | + return to_object |
| 65 | + |
| 66 | + |
| 67 | +def _VoiceConfig_to_vertex( |
| 68 | + api_client: BaseApiClient, |
| 69 | + from_object: Union[dict[str, Any], object], |
| 70 | + parent_object: Optional[dict[str, Any]] = None, |
| 71 | +) -> dict[str, Any]: |
| 72 | + to_object: dict[str, Any] = {} |
| 73 | + if getv(from_object, ['prebuilt_voice_config']) is not None: |
| 74 | + setv( |
| 75 | + to_object, |
| 76 | + ['prebuiltVoiceConfig'], |
| 77 | + _PrebuiltVoiceConfig_to_vertex( |
| 78 | + api_client, getv(from_object, ['prebuilt_voice_config']), to_object |
| 79 | + ), |
| 80 | + ) |
| 81 | + |
| 82 | + return to_object |
| 83 | + |
| 84 | + |
| 85 | +def _SpeakerVoiceConfig_to_mldev( |
| 86 | + api_client: BaseApiClient, |
| 87 | + from_object: Union[dict[str, Any], object], |
| 88 | + parent_object: Optional[dict[str, Any]] = None, |
| 89 | +) -> dict[str, Any]: |
| 90 | + to_object: dict[str, Any] = {} |
| 91 | + if getv(from_object, ['speaker']) is not None: |
| 92 | + setv(to_object, ['speaker'], getv(from_object, ['speaker'])) |
| 93 | + |
| 94 | + if getv(from_object, ['voice_config']) is not None: |
| 95 | + setv( |
| 96 | + to_object, |
| 97 | + ['voiceConfig'], |
| 98 | + _VoiceConfig_to_mldev( |
| 99 | + api_client, getv(from_object, ['voice_config']), to_object |
| 100 | + ), |
| 101 | + ) |
| 102 | + |
| 103 | + return to_object |
| 104 | + |
| 105 | + |
| 106 | +def _SpeakerVoiceConfig_to_vertex( |
| 107 | + api_client: BaseApiClient, |
| 108 | + from_object: Union[dict[str, Any], object], |
| 109 | + parent_object: Optional[dict[str, Any]] = None, |
| 110 | +) -> dict[str, Any]: |
| 111 | + to_object: dict[str, Any] = {} |
| 112 | + if getv(from_object, ['speaker']) is not None: |
| 113 | + raise ValueError('speaker parameter is not supported in Vertex AI.') |
| 114 | + |
| 115 | + if getv(from_object, ['voice_config']) is not None: |
| 116 | + raise ValueError('voice_config parameter is not supported in Vertex AI.') |
| 117 | + |
| 118 | + return to_object |
| 119 | + |
| 120 | + |
| 121 | +def _MultiSpeakerVoiceConfig_to_mldev( |
| 122 | + api_client: BaseApiClient, |
| 123 | + from_object: Union[dict[str, Any], object], |
| 124 | + parent_object: Optional[dict[str, Any]] = None, |
| 125 | +) -> dict[str, Any]: |
| 126 | + to_object: dict[str, Any] = {} |
| 127 | + if getv(from_object, ['speaker_voice_configs']) is not None: |
| 128 | + setv( |
| 129 | + to_object, |
| 130 | + ['speakerVoiceConfigs'], |
| 131 | + [ |
| 132 | + _SpeakerVoiceConfig_to_mldev(api_client, item, to_object) |
| 133 | + for item in getv(from_object, ['speaker_voice_configs']) |
| 134 | + ], |
| 135 | + ) |
| 136 | + |
| 137 | + return to_object |
| 138 | + |
| 139 | + |
| 140 | +def _MultiSpeakerVoiceConfig_to_vertex( |
| 141 | + api_client: BaseApiClient, |
| 142 | + from_object: Union[dict[str, Any], object], |
| 143 | + parent_object: Optional[dict[str, Any]] = None, |
| 144 | +) -> dict[str, Any]: |
| 145 | + to_object: dict[str, Any] = {} |
| 146 | + if getv(from_object, ['speaker_voice_configs']) is not None: |
| 147 | + raise ValueError( |
| 148 | + 'speaker_voice_configs parameter is not supported in Vertex AI.' |
| 149 | + ) |
| 150 | + |
| 151 | + return to_object |
| 152 | + |
| 153 | + |
| 154 | +def _SpeechConfig_to_mldev( |
| 155 | + api_client: BaseApiClient, |
| 156 | + from_object: Union[dict[str, Any], object], |
| 157 | + parent_object: Optional[dict[str, Any]] = None, |
| 158 | +) -> dict[str, Any]: |
| 159 | + to_object: dict[str, Any] = {} |
| 160 | + if getv(from_object, ['voice_config']) is not None: |
| 161 | + setv( |
| 162 | + to_object, |
| 163 | + ['voiceConfig'], |
| 164 | + _VoiceConfig_to_mldev( |
| 165 | + api_client, getv(from_object, ['voice_config']), to_object |
| 166 | + ), |
| 167 | + ) |
| 168 | + |
| 169 | + if getv(from_object, ['multi_speaker_voice_config']) is not None: |
| 170 | + setv( |
| 171 | + to_object, |
| 172 | + ['multiSpeakerVoiceConfig'], |
| 173 | + _MultiSpeakerVoiceConfig_to_mldev( |
| 174 | + api_client, |
| 175 | + getv(from_object, ['multi_speaker_voice_config']), |
| 176 | + to_object, |
| 177 | + ), |
| 178 | + ) |
| 179 | + |
| 180 | + if getv(from_object, ['language_code']) is not None: |
| 181 | + setv(to_object, ['languageCode'], getv(from_object, ['language_code'])) |
| 182 | + |
| 183 | + return to_object |
| 184 | + |
| 185 | + |
| 186 | +def _SpeechConfig_to_vertex( |
| 187 | + api_client: BaseApiClient, |
| 188 | + from_object: Union[dict[str, Any], object], |
| 189 | + parent_object: Optional[dict[str, Any]] = None, |
| 190 | +) -> dict[str, Any]: |
| 191 | + to_object: dict[str, Any] = {} |
| 192 | + if getv(from_object, ['voice_config']) is not None: |
| 193 | + setv( |
| 194 | + to_object, |
| 195 | + ['voiceConfig'], |
| 196 | + _VoiceConfig_to_vertex( |
| 197 | + api_client, getv(from_object, ['voice_config']), to_object |
| 198 | + ), |
| 199 | + ) |
| 200 | + |
| 201 | + if getv(from_object, ['multi_speaker_voice_config']) is not None: |
| 202 | + raise ValueError( |
| 203 | + 'multi_speaker_voice_config parameter is not supported in Vertex AI.' |
| 204 | + ) |
| 205 | + |
| 206 | + if getv(from_object, ['language_code']) is not None: |
| 207 | + setv(to_object, ['languageCode'], getv(from_object, ['language_code'])) |
| 208 | + |
| 209 | + return to_object |
| 210 | + |
| 211 | + |
25 | 212 | def _Blob_to_mldev( |
26 | 213 | api_client: BaseApiClient, |
27 | 214 | from_object: Union[dict[str, Any], object], |
@@ -1010,7 +1197,13 @@ def _LiveConnectConfig_to_mldev( |
1010 | 1197 | setv( |
1011 | 1198 | parent_object, |
1012 | 1199 | ['setup', 'generationConfig', 'speechConfig'], |
1013 | | - getv(from_object, ['speech_config']), |
| 1200 | + _SpeechConfig_to_mldev( |
| 1201 | + api_client, |
| 1202 | + t.t_live_speech_config( |
| 1203 | + api_client, getv(from_object, ['speech_config']) |
| 1204 | + ), |
| 1205 | + to_object, |
| 1206 | + ), |
1014 | 1207 | ) |
1015 | 1208 |
|
1016 | 1209 | if getv(from_object, ['system_instruction']) is not None: |
@@ -1154,7 +1347,13 @@ def _LiveConnectConfig_to_vertex( |
1154 | 1347 | setv( |
1155 | 1348 | parent_object, |
1156 | 1349 | ['setup', 'generationConfig', 'speechConfig'], |
1157 | | - getv(from_object, ['speech_config']), |
| 1350 | + _SpeechConfig_to_vertex( |
| 1351 | + api_client, |
| 1352 | + t.t_live_speech_config( |
| 1353 | + api_client, getv(from_object, ['speech_config']) |
| 1354 | + ), |
| 1355 | + to_object, |
| 1356 | + ), |
1158 | 1357 | ) |
1159 | 1358 |
|
1160 | 1359 | if getv(from_object, ['system_instruction']) is not None: |
|
0 commit comments