Lyria
The Lyria LOP connects to Google’s Lyria Realtime API to generate continuous music from text prompts. It streams audio directly into TouchDesigner as CHOP data at 48kHz, allowing real-time music generation that can be mixed, processed, and synchronized with visuals. Multiple weighted prompts can be blended together, and musical parameters like BPM, scale, density, and brightness can be adjusted while music is playing.
Requirements
Section titled “Requirements”- Gemini API Key: Obtain a key from Google AI Studio and enter it on the Lyria API page. The key is stored securely via ChatTD’s KeyManager.
- Python Package: The
google-genaipackage (version 1.16.0 or higher) must be installed. Use the Install/Update google-genai button on the Lyria API page, or Force Reinstall google-genai if you encounter version conflicts.
Input/Output
Section titled “Input/Output”Inputs
Section titled “Inputs”None — all configuration is done through parameters and text prompts.
Outputs
Section titled “Outputs”- Audio CHOP: Mono 48kHz audio output via the
store_outputCHOP. This progressive buffer accumulates all generated audio from the current session.
Usage Examples
Section titled “Usage Examples”Getting Started
Section titled “Getting Started”- On the Lyria API page, enter your Gemini API key in the Gemini API Key field (or pulse Get API Key to open Google AI Studio in your browser).
- If the
google-genaipackage is not installed, pulse Install/Update google-genai and wait for the installation to complete. You may need to restart TouchDesigner afterward. - Pulse Connect to Lyria to establish a connection to the Lyria Realtime API.
- On the Music Controls page, add a prompt in the Music Prompt sequence — enter descriptive text like “upbeat electronic dance music” and set the Weight (0.0 to 2.0).
- Pulse Play Music to start generating audio.
Blending Multiple Prompts
Section titled “Blending Multiple Prompts”- On the Music Controls page, add multiple entries to the Music Prompt sequence using the + button.
- Give each prompt a different style description (e.g., “ambient piano” at weight 1.0, “subtle jazz drums” at weight 0.5).
- Enable Auto Update Prompts to have changes sent to Lyria automatically as you adjust weights, or pulse Update Prompts on Lyria manually.
- Adjust weights in real time to crossfade between musical styles while the stream is playing.
Configuring Musical Parameters
Section titled “Configuring Musical Parameters”- On the Music Controls page, enable Enable BPM and set the desired BPM (30-240).
- Enable Enable Scale and choose a key from the Scale menu (e.g., “C Major / A Minor”).
- Use Enable Density (0.0-1.0) and Enable Brightness (0.0-1.0) to control the texture of the generated music.
- Toggle Enable Bass, Enable Drums, and Enable Other Instruments to mute or enable specific instrument groups.
- Set Generation Mode to “Quality (Stable)” for consistent output or “Diversity (Creative)” for more variation.
- Pulse Update Music Config to send changes to Lyria, then pulse Reset Stream Context if you changed BPM or Scale (these require a context reset to take effect).
Saving Generated Audio
Section titled “Saving Generated Audio”- On the Playback page, set the Output Folder to your desired save location (relative to the project file).
- Optionally set a Base Filename — if left at default, filenames are generated from your prompt text.
- Pulse Save Last Audio to save the current audio buffer as a 48kHz mono WAV file.
- Enable Autosave on Stop to automatically save whenever you pulse Stop Music.
- Toggle Clear on Save to control whether the audio buffer is cleared after saving (disable to keep audio for multiple saves).
Best Practices
Section titled “Best Practices”- Use descriptive style prompts rather than artist names. Lyria’s content filter blocks prompts referencing specific artists or copyrighted material. Describe the musical style instead (e.g., “groovy funk bass with syncopated rhythm” instead of a specific artist name).
- Adjust Temperature and Guidance together. Temperature (0.0-3.0) controls randomness while Guidance (0.0-6.0) controls how closely the output follows your prompts. Start with defaults and adjust incrementally.
- Enable Auto Connect on Play on the Lyria API page so that pulsing Play Music will automatically connect if you are disconnected.
- Use Auto Update Prompts for live performance. When enabled, prompt and weight changes are rate-limited (configurable via Auto Update Frequency) to avoid overwhelming the API while still allowing real-time control.
- Reset context after major changes. After changing BPM or Scale, pulse Reset Stream Context on the Music Controls page to apply those changes properly.
Troubleshooting
Section titled “Troubleshooting”- “google-genai not installed”: Pulse Install/Update google-genai on the Lyria API page. If the version is still below 1.16.0 after installing, use Force Reinstall google-genai and restart TouchDesigner.
- Connection errors: Pulse Diagnose Python Environment to check your SDK version and installation. Verify your API key is valid and that you have access to the Lyria model.
- Prompt filtered warnings: Lyria blocks prompts that reference specific artists, copyrighted material, or inappropriate content. Rewrite your prompts to describe the musical style generically.
- No audio after pressing Play: Ensure you have at least one prompt with a non-zero weight in the Music Prompt sequence. Prompts with empty text or zero weight are skipped.
- BPM/Scale changes not taking effect: These parameters require a context reset. After changing them, pulse Update Music Config followed by Reset Stream Context.
- SDK version conflicts: Use Diagnose Python Environment to check for multiple google-genai installations. Force Reinstall google-genai clears the pip cache and performs a clean install.
Research & Licensing
Google DeepMind
Google DeepMind is a leading AI research organization focused on developing artificial general intelligence. Their research spans reinforcement learning, natural language processing, computer vision, and creative AI, with a mission to solve intelligence and use it to advance scientific discovery and benefit humanity.
Lyria: Advanced Music Generation Model
Lyria is Google's advanced music generation model that builds upon research from MusicLM. It enables high-quality music generation from text prompts, supporting various musical styles and maintaining coherent structure across long-form compositions. The model is designed for integration into creative workflows and applications.
Technical Details
- Hierarchical Architecture: Multi-stage generation process with semantic and acoustic modeling
- Text Conditioning: Natural language descriptions guide music generation
- Temporal Coherence: Maintains musical structure across extended compositions
Research Impact
- Creative AI: Democratizing music creation through text-to-music generation
- Commercial Applications: Integration into Google's creative tools and services
- Research Foundation: Advancing the field of AI-generated creative content
Citation
@article{agostinelli2023musiclm,
title={MusicLM: Generating Music From Text},
author={Agostinelli, Andrea and Denk, Timo I. and Borsos, Zalán and Engel, Jesse and Verzetti, Mauro and Caillon, Antoine and Huang, Qingqing and Jansen, Aren and Roberts, Adam and Tagliasacchi, Marco and Sharifi, Matt and Zeghidour, Neil and Frank, Christian},
journal={arXiv preprint arXiv:2301.11325},
year={2023},
url={https://arxiv.org/abs/2301.11325}
} Key Research Contributions
- Hierarchical sequence-to-sequence modeling for high-quality music generation
- Conditioning on both text descriptions and melodic representations
- Long-form music generation with coherent structure and style
License
Proprietary - This model is freely available for research and commercial use.
Parameters
Section titled “Parameters”Music Controls
Section titled “Music Controls”op('lyria').par.Status Str - Default:
"" (Empty String)
op('lyria').par.Play Pulse - Default:
False
op('lyria').par.Pause Pulse - Default:
False
op('lyria').par.Stop Pulse - Default:
False
op('lyria').par.Resetcontext Pulse Use after significant config changes like BPM or Scale to apply them.
- Default:
False
op('lyria').par.Temperature Float - Default:
0.0- Range:
- 0 to 3
- Slider Range:
- 0 to 3
op('lyria').par.Guidance Float - Default:
0.0- Range:
- 0 to 6
- Slider Range:
- 0 to 6
op('lyria').par.Updateprompts Pulse Sends the current prompts from the internal table to Lyria.
- Default:
False
op('lyria').par.Autoupdateprompts Toggle Automatically update prompts on Lyria when sequence parameters change. Uses rate limiting to avoid API spam.
- Default:
False
op('lyria').par.Musicprompt Sequence - Default:
0
op('lyria').par.Musicprompt0text Str - Default:
"" (Empty String)
op('lyria').par.Musicprompt0weight Float - Default:
0.0- Range:
- 0 to 2
- Slider Range:
- 0 to 2
op('lyria').par.Enablebass Toggle - Default:
False
op('lyria').par.Enabledrums Toggle - Default:
False
op('lyria').par.Enableother Toggle Controls other instruments like melody, harmony, etc.
- Default:
False
op('lyria').par.Updateconfig Pulse - Default:
False
op('lyria').par.Enablebpm Toggle - Default:
False
op('lyria').par.Bpm Int - Default:
0- Range:
- 30 to 240
- Slider Range:
- 60 to 200
op('lyria').par.Enablescale Toggle - Default:
False
op('lyria').par.Enabledensity Toggle - Default:
False
op('lyria').par.Density Float - Default:
0.0- Range:
- 0 to 1
- Slider Range:
- 0 to 1
op('lyria').par.Enablebrightness Toggle - Default:
False
op('lyria').par.Brightness Float - Default:
0.0- Range:
- 0 to 1
- Slider Range:
- 0 to 1
Lyria API
Section titled “Lyria API”op('lyria').par.Status2 Str - Default:
"" (Empty String)
op('lyria').par.Connect Pulse - Default:
False
op('lyria').par.Disconnect Pulse - Default:
False
op('lyria').par.Model Str The specific Lyria model to use for generation.
- Default:
"" (Empty String)
op('lyria').par.Listavailablemodels Pulse Lists all models accessible by the current API key and logs them.
- Default:
False
op('lyria').par.Apikey Str Enter your Gemini API key from Google AI Studio. It will be stored securely.
- Default:
"" (Empty String)
op('lyria').par.Getapikey Pulse Opens Google AI Studio in your browser to get an API key.
- Default:
False
op('lyria').par.Installgooglegenai Pulse Installs or updates the google-generativeai Python package via ChatTD PackageManager.
- Default:
False
op('lyria').par.Testlyriamodel Pulse Tests direct connection to the Lyria model (models/lyria-realtime-exp) to verify availability.
- Default:
False
op('lyria').par.Forcereinstallgenai Pulse Force reinstalls google-genai>=1.16.0 with cache clearing to resolve version conflicts.
- Default:
False
op('lyria').par.Diagnosepythonenv Pulse Diagnoses Python environment issues that might prevent SDK updates.
- Default:
False
op('lyria').par.Autoconnect Toggle If enabled, hitting 'Play' while disconnected will automatically attempt to connect to Lyria.
- Default:
False
op('lyria').par.Autoupdatefrequency Float Delay in seconds for auto-updating prompts.
- Default:
0.0- Range:
- 0 to 1
- Slider Range:
- 0.2 to 5
Playback
Section titled “Playback”op('lyria').par.Audioactive Toggle - Default:
True
op('lyria').par.Volume Float - Default:
1.0- Range:
- 0 to 1
- Slider Range:
- 0 to 1
op('lyria').par.Clearaudio Pulse Clears all generated audio from memory and from the output CHOPs (store_output and full_audio).
- Default:
False
op('lyria').par.Savelastaudio Pulse Manually save the contents of the current audio buffer to a file.
- Default:
False
op('lyria').par.Basefilename Str The base name for saved audio files. A timestamp will be appended to ensure uniqueness.
- Default:
"" (Empty String)
op('lyria').par.Outputfolder Folder The folder where generated audio files will be saved, relative to the project file.
- Default:
"" (Empty String)
op('lyria').par.Autosaveonstop Toggle Automatically save the audio buffer to a file when the stream is stopped.
- Default:
False
op('lyria').par.Clearonsave Toggle Clear the audio buffer after saving. Disable to keep audio for multiple saves.
- Default:
False
Changelog
Section titled “Changelog”v1.0.02025-06-26
First release / finalized version
- added playback parameter page that controls the playback of the audio.
- added a new parameter
Clearaudioto clear the audio buffers. - added auto updateprompts and a poll paramter for updates ever X second
- added auto saving of the audio on stop stream + a few more configurable options . set on the playback page.
v0.2.02025-05-20
first release