Generated banner for Mood Music
Generated logo for Mood Music

Mood Music

Google AI EdgeOfficialPublished by Google AI Edge

  • Skill
  • Tool integration
  • Automation and integrations
  • Apache-2.0
  • No issues found

From the author

A skill to suggest or play music based on the user's mood, including analyzing images or audio, by querying available genres and generating music via the Loudly API.
— the description by Google AI Edge

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

Mood Music is a tool-integration skill that enables AI agents to generate personalized music tracks. By leveraging the Loudly API, the skill allows users to request music based on specific moods or by providing media inputs like images or audio. It follows a structured two-step process: first, it retrieves the current list of supported musical genres to ensure compatibility, and then it maps the user's emotional or media-based input to those genres to generate a tailored audio file.

What it does

  • Fetches a list of supported musical genres from the Loudly API.
  • Analyzes text-based mood descriptions to select appropriate musical styles.
  • Processes images or audio clips to interpret their vibe and atmosphere.
  • Generates custom music tracks with configurable parameters like duration, energy, and BPM.
  • Supports genre blending for more complex musical compositions.

When to use it

  • When you need background music that matches a specific emotional state.
  • When you want to create a soundtrack for a photo or an existing audio clip.
  • When you need to generate unique music tracks for creative projects.
  • When you want to explore different musical genres and energy levels for a playlist.

Advantages

  • Ensures high compatibility by dynamically fetching supported genres.
  • Allows for precise control over music characteristics like tempo and energy.
  • Enables multimodal input by supporting both text and media analysis.
  • Simplifies the music generation process through a standardized two-step workflow.

Usage examples

“I am feeling relaxed and want some lo-fi music for reading.”
The agent fetches the genre list, identifies a matching lo-fi genre, and generates a 120-second track with low energy.
“Create a high-energy track that matches the vibe of this sunset photo.”
The agent analyzes the image, selects a genre that fits the sunset aesthetic, and generates a high-energy music track.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/google-ai-edge/mood-music/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip mood-music.zip -d .agents/skills

Documentation by Google AI Edge

Mood Music

Instructions

You MUST use a strict two-step process to generate music. This ensures you only request musical genres that are currently supported by the Loudly API.

Step 1: Fetch Available Genres

Call the run_js tool with get_genres.html as the script name and an empty JSON payload ({}).

  • This will return a list of currently available genres and their descriptions.

  • You MUST review this list to understand the available musical palettes.

Step 2: Analyze and Generate

Once you have the valid genres, map the user's request to the best fit and call run_js with index.html to generate the track.

Handling Inputs:

  • Text Inputs: Translate abstract mood requests into a concrete, matching genre from the fetched list, along with an appropriate energy level.

  • Media Inputs (Images/Audio): If the user provides an image or audio clip, analyze the media to determine its underlying mood, atmosphere, or vibe. Translate this analysis strictly into one of the fetched genres.

Generation Payload (for index.html): Your JSON payload for index.html MUST strictly use these text fields to represent the vibe:

  • genre: String, Required. MUST be an exact match to a genre name retrieved in Step 1.

  • genre_blend: String, Optional. A secondary genre to blend (also from Step 1).

  • duration: Integer, Optional. Length in seconds (30-420). Default is 120.

  • energy: String, Optional. Vibe ("low", "high", "original").

  • bpm: Integer, Optional. Specific tempo in Beats Per Minute.

Invocation Triggers

You should invoke this skill when the user:

  • Asks for music for a specific mood.

  • Asks for playlist ideas for a vibe.

  • Uploads an image or audio clip and asks for music to match it.

Files

scripts/index.html

<!--
@license
Copyright 2026 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================
-->

<!doctype html>
<html lang="en">
  <body>
    <script>
      window["ai_edge_gallery_get_result"] = async (data, secret) => {
        try {
          const jsonData = JSON.parse(data);

          // The LLM has already validated the genre in Step 1, so we use it directly
          const genre = jsonData.genre || "House";
          const duration = jsonData.duration || 120;

          let energy = jsonData.energy || "high";
          if (!["low", "high", "original"].includes(energy)) {
            energy = "original"; // Fallback for invalid options
          }

          // 1. Retrieve the API secret passed from the native system
          const apiKey = secret || "YOUR_API_KEY_HERE";

          if (apiKey === "YOUR_API_KEY_HERE") {
            console.warn("Using placeholder API Key, calls to Loudly will likely fail.");
          }

          // 2. Prepare FormData as expected by the Loudly API
          const formData = new FormData();
          formData.append("genre", genre);
          formData.append("duration", duration);
          formData.append("energy", energy);

          // 3. Call Loudly soundtracks API
          const response = await fetch("https://soundtracks.loudly.com/api/ai/songs", {
            method: "POST",
            headers: {
              "API-KEY": apiKey,
              Accept: "application/json",
            },
            body: formData,
          });

          if (!response.ok) {
            const errorText = await response.text();
            throw new Error(`Loudly API failed with status ${response.status}: ${errorText}`);
          }

          const songData = await response.json();

          // 4. Extract the correct fields based on Loudly's JSON structure
          const audioUrl = songData.music_file_path || "";
          const songTitle = songData.title || "Generated Track";

          // 5. Return the result and instructions for the UI webview
          return JSON.stringify({
            webview: {
              // Point to webview.html and pass the parsed data via query parameters
              url: `webview.html?url=${encodeURIComponent(audioUrl)}&duration=${duration}&genre=${encodeURIComponent(genre)}&title=${encodeURIComponent(songTitle)}`,
            },
          });
        } catch (e) {
          console.error(e);
          return JSON.stringify({ error: `Music generation failed: ${e.message}` });
        }
      };
    </script>

    <!-- Test UI -->
    <div
      style="
        margin: 20px;
        padding: 20px;
        border: 1px solid #ccc;
        background: #fff;
        font-family: sans-serif;
        color: #333;
      "
    >
      <h3>Mood Music Local Scenario Test Area</h3>
      <button id="run-test" style="padding: 10px 20px; font-size: 16px; cursor: pointer">
        Run Generation Test
      </button>
      <pre
        id="test-output"
        style="
          margin-top: 15px;
          padding: 10px;
          background: #f4f4f4;
          border: 1px solid #ddd;
          white-space: pre-wrap;
          font-size: 13px;
        "
      ></pre>
    </div>

    <script>
      document.getElementById("run-test").addEventListener("click", async () => {
        const output = document.getElementById("test-output");
        output.textContent = "Running test...";
        try {
          const mockLLMPayload = JSON.stringify({
            genre: "Lo Fi",
            energy: "original",
            duration: 240,
          });
          const result = await window["ai_edge_gallery_get_result"](mockLLMPayload);
          output.textContent = result;
        } catch (e) {
          output.textContent = `Crash Error: ${e.message}`;
        }
      });
    </script>
  </body>
</html>

Requirements and compatibility

Written for: Google AI Edge Gallery

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
Google AI Edge
Publisher
Google AI Edge (Official)
Source
google-ai-edge/gallery · skills/featured/mood-music · commit 3972f06
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Google AI Edge or Google AI Edge.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download mood-music.zip