File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -189,6 +189,37 @@ interaction.outputs().forEach(content -> {
189189});
190190```
191191
192+ ### Lyria Music Generation
193+ ``` java
194+ import io.github.glaforge.gemini.interactions.model.Content.* ;
195+ import io.github.glaforge.gemini.interactions.model.InteractionParams.ModelInteractionParams ;
196+ import io.github.glaforge.gemini.interactions.model.Interaction.Modality ;
197+ import java.nio.file.Files ;
198+ import java.nio.file.Paths ;
199+
200+ ModelInteractionParams request = ModelInteractionParams . builder()
201+ .model(" models/lyria-3-clip-preview" )
202+ .input(" An epic song with opera voices about a quest. Deep synths and a speeding up tempo." )
203+ .responseModalities(Modality . AUDIO , Modality . TEXT )
204+ .build();
205+
206+ Interaction interaction = client. create(request);
207+
208+ interaction. outputs(). forEach(content - > {
209+ if (content instanceof TextContent text) {
210+ System . out. println(" Lyrics / Structure Generated:\\ n" + text. text());
211+ }
212+ if (content instanceof AudioContent audio) {
213+ // Lyria directly returns an encoded MP3 byte stream!
214+ try {
215+ Files . write(Paths . get(" quest-song.mp3" ), audio. data());
216+ } catch (Exception e) {
217+ e. printStackTrace();
218+ }
219+ }
220+ });
221+ ```
222+
192223### Deep Research
193224``` java
194225import io.github.glaforge.gemini.interactions.model.Interaction ;
You can’t perform that action at this time.
0 commit comments