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, and seed) 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 via tools._discord_helpers.get_discord_client(), then uses ctx.adapter.lyria_service (services.lyria_service.LyriaService) — first calling its is_playing guard and finally its async steer to push the new prompts and config_updates to the running session. Weighted prompt strings are parsed with services.lyria_session.parse_prompts(), and google.genai.types is consulted to resolve the scale and music_generation_mode enums. As the single-tool module’s entry point it is registered under TOOL_NAME (steer_music) by tool_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 against types.Scale.

  • music_generation_mode (str) – Generation mode enum name resolved against types.MusicGenerationMode (QUALITY/DIVERSITY/ VOCALIZATION).

  • guidance (float) – Prompt-adherence strength; range-checked to 0.06.0.

  • density (float) – Note density; range-checked to 0.01.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 to 11000.

  • seed (int) – Random seed; range-checked to 02147483647.

  • ctx (ToolContext | None) – Tool context supplying adapter (with lyria_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:

str