tools.music_steering module
Real-time music steering for Lyria RealTime via ctx.adapter.
- async tools.music_steering.run(guild_id, prompt=None, bpm=None, temperature=None, brightness=None, scale=None, music_generation_mode=None, guidance=None, density=None, mute_bass=None, mute_drums=None, only_bass_and_drums=None, top_k=None, seed=None, ctx=None)[source]
Steer the currently playing Lyria RealTime music session in real time.
Applies the supplied subset of generation parameters (weighted prompts, BPM, temperature, brightness, scale, generation mode, guidance, density, the bass/drums muting flags,
top_k, andseed) to a live music stream so the model can nudge the soundtrack without restarting it. Each provided value is validated and range-checked, and a human-readable summary of exactly what changed is returned.Reaches the audio engine through the inference worker’s
ctx.adapter(core.proxy_adapter.ProxyPlatformAdapter): it pulls the Discord client viatools._discord_helpers.get_discord_client(), then usesctx.adapter.lyria_service(services.lyria_service.LyriaService) — first calling itsis_playingguard and finally its asyncsteerto push the new prompts andconfig_updatesto the running session. Weighted prompt strings are parsed withservices.lyria_session.parse_prompts(), andgoogle.genai.typesis consulted to resolve thescaleandmusic_generation_modeenums. As the single-tool module’s entry point it is registered underTOOL_NAME(steer_music) bytool_loader.load_tools_from_directory()and invoked by the inference worker’s tool-execution path; it is not called directly elsewhere in the repo.- Parameters:
guild_id (
str) – Discord guild (server) id of the active session; must parse to an int and have music currently playing.prompt (
str) – New weighted prompt string (e.g."epic rock:1.5, calm strings:0.5"); parsed into weighted prompts.bpm (
int) – New tempo in beats per minute.temperature (
float) – New creativity/sampling temperature.brightness (
float) – New tonal brightness.scale (
str) – Musical scale enum name resolved againsttypes.Scale.music_generation_mode (
str) – Generation mode enum name resolved againsttypes.MusicGenerationMode(QUALITY/DIVERSITY/VOCALIZATION).guidance (
float) – Prompt-adherence strength; range-checked to0.0–6.0.density (
float) – Note density; range-checked to0.0–1.0.mute_bass (
bool) – When set, reduce/mute the bass.mute_drums (
bool) – When set, reduce/mute the drums.only_bass_and_drums (
bool) – When set, restrict output to bass and drums.top_k (
int) – Sampling parameter; range-checked to1–1000.seed (
int) – Random seed; range-checked to0–2147483647.ctx (
ToolContext|None) – Tool context supplyingadapter(withlyria_service). Required; a missing adapter yields an error result.
- Returns:
A human-readable success message naming every parameter that was steered, or an error string (missing adapter/client, invalid
guild_id, no active playback, an invalid value, or no parameters supplied).- Return type: