Skip to content

Commit 959c01b

Browse files
MarkDaoustcopybara-github
authored andcommitted
feat: [Python] Add consent_audio and voice_consent_signature and AsyncSession.setup_complete
PiperOrigin-RevId: 888366910
1 parent 6c35249 commit 959c01b

6 files changed

Lines changed: 421 additions & 20 deletions

File tree

src/main/java/com/google/genai/LiveConverters.java

Lines changed: 126 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,10 @@ ObjectNode generationConfigToVertex(JsonNode fromObject, ObjectNode parentObject
381381
Common.setValueByPath(
382382
toObject,
383383
new String[] {"speechConfig"},
384-
Common.getValueByPath(fromObject, new String[] {"speechConfig"}));
384+
speechConfigToVertex(
385+
JsonSerializable.toJsonNode(
386+
Common.getValueByPath(fromObject, new String[] {"speechConfig"})),
387+
toObject));
385388
}
386389

387390
if (Common.getValueByPath(fromObject, new String[] {"stopSequences"}) != null) {
@@ -1164,8 +1167,11 @@ ObjectNode liveConnectConfigToVertex(JsonNode fromObject, ObjectNode parentObjec
11641167
Common.setValueByPath(
11651168
parentObject,
11661169
new String[] {"setup", "generationConfig", "speechConfig"},
1167-
Transformers.tLiveSpeechConfig(
1168-
Common.getValueByPath(fromObject, new String[] {"speechConfig"})));
1170+
speechConfigToVertex(
1171+
JsonSerializable.toJsonNode(
1172+
Transformers.tLiveSpeechConfig(
1173+
Common.getValueByPath(fromObject, new String[] {"speechConfig"}))),
1174+
toObject));
11691175
}
11701176

11711177
if (Common.getValueByPath(fromObject, new String[] {"thinkingConfig"}) != null) {
@@ -1579,6 +1585,24 @@ ObjectNode liveServerMessageFromVertex(JsonNode fromObject, ObjectNode parentObj
15791585
return toObject;
15801586
}
15811587

1588+
@ExcludeFromGeneratedCoverageReport
1589+
ObjectNode multiSpeakerVoiceConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
1590+
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
1591+
if (Common.getValueByPath(fromObject, new String[] {"speakerVoiceConfigs"}) != null) {
1592+
ArrayNode keyArray =
1593+
(ArrayNode) Common.getValueByPath(fromObject, new String[] {"speakerVoiceConfigs"});
1594+
ObjectMapper objectMapper = new ObjectMapper();
1595+
ArrayNode result = objectMapper.createArrayNode();
1596+
1597+
for (JsonNode item : keyArray) {
1598+
result.add(speakerVoiceConfigToVertex(JsonSerializable.toJsonNode(item), toObject));
1599+
}
1600+
Common.setValueByPath(toObject, new String[] {"speakerVoiceConfigs"}, result);
1601+
}
1602+
1603+
return toObject;
1604+
}
1605+
15821606
@ExcludeFromGeneratedCoverageReport
15831607
ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject) {
15841608
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
@@ -1787,6 +1811,26 @@ ObjectNode partToVertex(JsonNode fromObject, ObjectNode parentObject) {
17871811
return toObject;
17881812
}
17891813

1814+
@ExcludeFromGeneratedCoverageReport
1815+
ObjectNode replicatedVoiceConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
1816+
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
1817+
if (Common.getValueByPath(fromObject, new String[] {"mimeType"}) != null) {
1818+
Common.setValueByPath(
1819+
toObject,
1820+
new String[] {"mimeType"},
1821+
Common.getValueByPath(fromObject, new String[] {"mimeType"}));
1822+
}
1823+
1824+
if (Common.getValueByPath(fromObject, new String[] {"voiceSampleAudio"}) != null) {
1825+
Common.setValueByPath(
1826+
toObject,
1827+
new String[] {"voiceSampleAudio"},
1828+
Common.getValueByPath(fromObject, new String[] {"voiceSampleAudio"}));
1829+
}
1830+
1831+
return toObject;
1832+
}
1833+
17901834
@ExcludeFromGeneratedCoverageReport
17911835
ObjectNode sessionResumptionConfigToMldev(JsonNode fromObject, ObjectNode parentObject) {
17921836
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
@@ -1804,6 +1848,62 @@ ObjectNode sessionResumptionConfigToMldev(JsonNode fromObject, ObjectNode parent
18041848
return toObject;
18051849
}
18061850

1851+
@ExcludeFromGeneratedCoverageReport
1852+
ObjectNode speakerVoiceConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
1853+
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
1854+
if (Common.getValueByPath(fromObject, new String[] {"speaker"}) != null) {
1855+
Common.setValueByPath(
1856+
toObject,
1857+
new String[] {"speaker"},
1858+
Common.getValueByPath(fromObject, new String[] {"speaker"}));
1859+
}
1860+
1861+
if (Common.getValueByPath(fromObject, new String[] {"voiceConfig"}) != null) {
1862+
Common.setValueByPath(
1863+
toObject,
1864+
new String[] {"voiceConfig"},
1865+
voiceConfigToVertex(
1866+
JsonSerializable.toJsonNode(
1867+
Common.getValueByPath(fromObject, new String[] {"voiceConfig"})),
1868+
toObject));
1869+
}
1870+
1871+
return toObject;
1872+
}
1873+
1874+
@ExcludeFromGeneratedCoverageReport
1875+
ObjectNode speechConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
1876+
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
1877+
if (Common.getValueByPath(fromObject, new String[] {"voiceConfig"}) != null) {
1878+
Common.setValueByPath(
1879+
toObject,
1880+
new String[] {"voiceConfig"},
1881+
voiceConfigToVertex(
1882+
JsonSerializable.toJsonNode(
1883+
Common.getValueByPath(fromObject, new String[] {"voiceConfig"})),
1884+
toObject));
1885+
}
1886+
1887+
if (Common.getValueByPath(fromObject, new String[] {"languageCode"}) != null) {
1888+
Common.setValueByPath(
1889+
toObject,
1890+
new String[] {"languageCode"},
1891+
Common.getValueByPath(fromObject, new String[] {"languageCode"}));
1892+
}
1893+
1894+
if (Common.getValueByPath(fromObject, new String[] {"multiSpeakerVoiceConfig"}) != null) {
1895+
Common.setValueByPath(
1896+
toObject,
1897+
new String[] {"multiSpeakerVoiceConfig"},
1898+
multiSpeakerVoiceConfigToVertex(
1899+
JsonSerializable.toJsonNode(
1900+
Common.getValueByPath(fromObject, new String[] {"multiSpeakerVoiceConfig"})),
1901+
toObject));
1902+
}
1903+
1904+
return toObject;
1905+
}
1906+
18071907
@ExcludeFromGeneratedCoverageReport
18081908
ObjectNode toolToMldev(JsonNode fromObject, ObjectNode parentObject) {
18091909
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
@@ -2090,4 +2190,27 @@ ObjectNode voiceActivityFromVertex(JsonNode fromObject, ObjectNode parentObject)
20902190

20912191
return toObject;
20922192
}
2193+
2194+
@ExcludeFromGeneratedCoverageReport
2195+
ObjectNode voiceConfigToVertex(JsonNode fromObject, ObjectNode parentObject) {
2196+
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
2197+
if (Common.getValueByPath(fromObject, new String[] {"replicatedVoiceConfig"}) != null) {
2198+
Common.setValueByPath(
2199+
toObject,
2200+
new String[] {"replicatedVoiceConfig"},
2201+
replicatedVoiceConfigToVertex(
2202+
JsonSerializable.toJsonNode(
2203+
Common.getValueByPath(fromObject, new String[] {"replicatedVoiceConfig"})),
2204+
toObject));
2205+
}
2206+
2207+
if (Common.getValueByPath(fromObject, new String[] {"prebuiltVoiceConfig"}) != null) {
2208+
Common.setValueByPath(
2209+
toObject,
2210+
new String[] {"prebuiltVoiceConfig"},
2211+
Common.getValueByPath(fromObject, new String[] {"prebuiltVoiceConfig"}));
2212+
}
2213+
2214+
return toObject;
2215+
}
20932216
}

src/main/java/com/google/genai/Models.java

Lines changed: 138 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,8 +1818,12 @@ ObjectNode generateContentConfigToVertex(
18181818
Common.setValueByPath(
18191819
toObject,
18201820
new String[] {"speechConfig"},
1821-
Transformers.tSpeechConfig(
1822-
Common.getValueByPath(fromObject, new String[] {"speechConfig"})));
1821+
speechConfigToVertex(
1822+
JsonSerializable.toJsonNode(
1823+
Transformers.tSpeechConfig(
1824+
Common.getValueByPath(fromObject, new String[] {"speechConfig"}))),
1825+
toObject,
1826+
rootObject));
18231827
}
18241828

18251829
if (Common.getValueByPath(fromObject, new String[] {"audioTimestamp"}) != null) {
@@ -3305,7 +3309,11 @@ ObjectNode generationConfigToVertex(
33053309
Common.setValueByPath(
33063310
toObject,
33073311
new String[] {"speechConfig"},
3308-
Common.getValueByPath(fromObject, new String[] {"speechConfig"}));
3312+
speechConfigToVertex(
3313+
JsonSerializable.toJsonNode(
3314+
Common.getValueByPath(fromObject, new String[] {"speechConfig"})),
3315+
toObject,
3316+
rootObject));
33093317
}
33103318

33113319
if (Common.getValueByPath(fromObject, new String[] {"stopSequences"}) != null) {
@@ -4021,6 +4029,26 @@ ObjectNode modelFromVertex(JsonNode fromObject, ObjectNode parentObject, JsonNod
40214029
return toObject;
40224030
}
40234031

4032+
@ExcludeFromGeneratedCoverageReport
4033+
ObjectNode multiSpeakerVoiceConfigToVertex(
4034+
JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) {
4035+
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
4036+
if (Common.getValueByPath(fromObject, new String[] {"speakerVoiceConfigs"}) != null) {
4037+
ArrayNode keyArray =
4038+
(ArrayNode) Common.getValueByPath(fromObject, new String[] {"speakerVoiceConfigs"});
4039+
ObjectMapper objectMapper = new ObjectMapper();
4040+
ArrayNode result = objectMapper.createArrayNode();
4041+
4042+
for (JsonNode item : keyArray) {
4043+
result.add(
4044+
speakerVoiceConfigToVertex(JsonSerializable.toJsonNode(item), toObject, rootObject));
4045+
}
4046+
Common.setValueByPath(toObject, new String[] {"speakerVoiceConfigs"}, result);
4047+
}
4048+
4049+
return toObject;
4050+
}
4051+
40244052
@ExcludeFromGeneratedCoverageReport
40254053
ObjectNode partToMldev(JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) {
40264054
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
@@ -4493,6 +4521,27 @@ ObjectNode referenceImageAPIToVertex(
44934521
return toObject;
44944522
}
44954523

4524+
@ExcludeFromGeneratedCoverageReport
4525+
ObjectNode replicatedVoiceConfigToVertex(
4526+
JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) {
4527+
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
4528+
if (Common.getValueByPath(fromObject, new String[] {"mimeType"}) != null) {
4529+
Common.setValueByPath(
4530+
toObject,
4531+
new String[] {"mimeType"},
4532+
Common.getValueByPath(fromObject, new String[] {"mimeType"}));
4533+
}
4534+
4535+
if (Common.getValueByPath(fromObject, new String[] {"voiceSampleAudio"}) != null) {
4536+
Common.setValueByPath(
4537+
toObject,
4538+
new String[] {"voiceSampleAudio"},
4539+
Common.getValueByPath(fromObject, new String[] {"voiceSampleAudio"}));
4540+
}
4541+
4542+
return toObject;
4543+
}
4544+
44964545
@ExcludeFromGeneratedCoverageReport
44974546
ObjectNode safetyAttributesFromMldev(
44984547
JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) {
@@ -4733,6 +4782,67 @@ ObjectNode segmentImageSourceToVertex(
47334782
return toObject;
47344783
}
47354784

4785+
@ExcludeFromGeneratedCoverageReport
4786+
ObjectNode speakerVoiceConfigToVertex(
4787+
JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) {
4788+
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
4789+
if (Common.getValueByPath(fromObject, new String[] {"speaker"}) != null) {
4790+
Common.setValueByPath(
4791+
toObject,
4792+
new String[] {"speaker"},
4793+
Common.getValueByPath(fromObject, new String[] {"speaker"}));
4794+
}
4795+
4796+
if (Common.getValueByPath(fromObject, new String[] {"voiceConfig"}) != null) {
4797+
Common.setValueByPath(
4798+
toObject,
4799+
new String[] {"voiceConfig"},
4800+
voiceConfigToVertex(
4801+
JsonSerializable.toJsonNode(
4802+
Common.getValueByPath(fromObject, new String[] {"voiceConfig"})),
4803+
toObject,
4804+
rootObject));
4805+
}
4806+
4807+
return toObject;
4808+
}
4809+
4810+
@ExcludeFromGeneratedCoverageReport
4811+
ObjectNode speechConfigToVertex(
4812+
JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) {
4813+
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
4814+
if (Common.getValueByPath(fromObject, new String[] {"voiceConfig"}) != null) {
4815+
Common.setValueByPath(
4816+
toObject,
4817+
new String[] {"voiceConfig"},
4818+
voiceConfigToVertex(
4819+
JsonSerializable.toJsonNode(
4820+
Common.getValueByPath(fromObject, new String[] {"voiceConfig"})),
4821+
toObject,
4822+
rootObject));
4823+
}
4824+
4825+
if (Common.getValueByPath(fromObject, new String[] {"languageCode"}) != null) {
4826+
Common.setValueByPath(
4827+
toObject,
4828+
new String[] {"languageCode"},
4829+
Common.getValueByPath(fromObject, new String[] {"languageCode"}));
4830+
}
4831+
4832+
if (Common.getValueByPath(fromObject, new String[] {"multiSpeakerVoiceConfig"}) != null) {
4833+
Common.setValueByPath(
4834+
toObject,
4835+
new String[] {"multiSpeakerVoiceConfig"},
4836+
multiSpeakerVoiceConfigToVertex(
4837+
JsonSerializable.toJsonNode(
4838+
Common.getValueByPath(fromObject, new String[] {"multiSpeakerVoiceConfig"})),
4839+
toObject,
4840+
rootObject));
4841+
}
4842+
4843+
return toObject;
4844+
}
4845+
47364846
@ExcludeFromGeneratedCoverageReport
47374847
ObjectNode toolConfigToMldev(JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) {
47384848
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
@@ -5445,6 +5555,31 @@ ObjectNode videoToVertex(JsonNode fromObject, ObjectNode parentObject, JsonNode
54455555
return toObject;
54465556
}
54475557

5558+
@ExcludeFromGeneratedCoverageReport
5559+
ObjectNode voiceConfigToVertex(
5560+
JsonNode fromObject, ObjectNode parentObject, JsonNode rootObject) {
5561+
ObjectNode toObject = JsonSerializable.objectMapper().createObjectNode();
5562+
if (Common.getValueByPath(fromObject, new String[] {"replicatedVoiceConfig"}) != null) {
5563+
Common.setValueByPath(
5564+
toObject,
5565+
new String[] {"replicatedVoiceConfig"},
5566+
replicatedVoiceConfigToVertex(
5567+
JsonSerializable.toJsonNode(
5568+
Common.getValueByPath(fromObject, new String[] {"replicatedVoiceConfig"})),
5569+
toObject,
5570+
rootObject));
5571+
}
5572+
5573+
if (Common.getValueByPath(fromObject, new String[] {"prebuiltVoiceConfig"}) != null) {
5574+
Common.setValueByPath(
5575+
toObject,
5576+
new String[] {"prebuiltVoiceConfig"},
5577+
Common.getValueByPath(fromObject, new String[] {"prebuiltVoiceConfig"}));
5578+
}
5579+
5580+
return toObject;
5581+
}
5582+
54485583
/** A shared buildRequest method for both sync and async methods. */
54495584
BuiltRequest buildRequestForPrivateGenerateContent(
54505585
String model, List<Content> contents, GenerateContentConfig config) {

0 commit comments

Comments
 (0)