# Sonauto V2

> Extend an existing song


## Overview

- **Endpoint**: `https://fal.run/sonauto/v2/extend`
- **Model ID**: `sonauto/v2/extend`
- **Category**: audio-to-audio
- **Kind**: inference
**Tags**: music, text-to-music, text-to-audio



## Pricing

- **Price**: $0.075 per generations

For more details, see [fal.ai pricing](https://fal.ai/pricing).

## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:


- **`prompt`** (`string`, _optional_):
  A description of the track you want to generate. This prompt will be used to automatically generate the tags and lyrics unless you manually set them. For example, if you set prompt and tags, then the prompt will be used to generate only the lyrics.
  - Examples: "Add a beginning to the song"

- **`tags`** (`list<string>`, _optional_):
  Tags/styles of the music to generate. You can view a list of all available tags at https://sonauto.ai/tag-explorer.
  - Array of string

- **`lyrics_prompt`** (`string`, _optional_):
  The lyrics sung in the generated song. An empty string will generate an instrumental track.

- **`seed`** (`integer`, _optional_):
  The seed to use for generation. Will pick a random seed if not provided. Repeating a request with identical parameters (must use lyrics and tags, not prompt) and the same seed will generate the same song.
  - Range: `-9223372036854776000` to `9223372036854776000`

- **`prompt_strength`** (`float`, _optional_):
  Controls how strongly your prompt influences the output. Greater values adhere more to the prompt but sound less natural. (This is CFG.) Default value: `1.8`
  - Default: `1.8`
  - Range: `1.4` to `3.1`

- **`balance_strength`** (`float`, _optional_):
  Greater means more natural vocals. Lower means sharper instrumentals. We recommend 0.7. Default value: `0.7`
  - Default: `0.7`
  - Range: `0` to `1`

- **`num_songs`** (`integer`, _optional_):
  Generating 2 songs costs 1.5x the price of generating 1 song. Also, note that using the same seed may not result in identical songs if the number of songs generated is changed. Default value: `1`
  - Default: `1`
  - Range: `1` to `2`

- **`output_format`** (`OutputFormatEnum`, _optional_):
   Default value: `"wav"`
  - Default: `"wav"`
  - Options: `"flac"`, `"mp3"`, `"wav"`, `"ogg"`, `"m4a"`

- **`output_bit_rate`** (`Enum`, _optional_):
  The bit rate to use for mp3 and m4a formats. Not available for other formats.
  - Options: `128`, `192`, `256`, `320`

- **`audio_url`** (`string`, _required_):
  The URL of the audio file to alter. Must be a valid publicly accessible URL.
  - Examples: "https://cdn.sonauto.ai/generations2_altformats/audio_c5e63f7c-fc79-4322-808d-c09911af4713.wav"

- **`side`** (`SideEnum`, _required_):
  Add more to the beginning (left) or end (right) of the song
  - Options: `"left"`, `"right"`

- **`extend_duration`** (`float`, _optional_):
  Duration in seconds to extend the song. If not provided, will attempt to automatically determine.
  - Range: `2` to `85`

- **`crop_duration`** (`float`, _optional_):
  Duration in seconds to crop from the selected side before extending from that side.
  - Default: `0`



**Required Parameters Example**:

```json
{
  "audio_url": "https://cdn.sonauto.ai/generations2_altformats/audio_c5e63f7c-fc79-4322-808d-c09911af4713.wav",
  "side": "left"
}
```

**Full Example**:

```json
{
  "prompt": "Add a beginning to the song",
  "prompt_strength": 1.8,
  "balance_strength": 0.7,
  "num_songs": 1,
  "output_format": "wav",
  "audio_url": "https://cdn.sonauto.ai/generations2_altformats/audio_c5e63f7c-fc79-4322-808d-c09911af4713.wav",
  "side": "left"
}
```


### Output Schema

The API returns the following output format:

- **`seed`** (`integer`, _required_):
  The seed used for generation. This can be used to generate an identical song by passing the same parameters with this seed in a future request.
  - Examples: 42

- **`tags`** (`list<string>`, _optional_):
  The style tags used for generation.
  - Array of string

- **`lyrics`** (`string`, _optional_):
  The lyrics used for generation.

- **`audio`** (`list<File>`, _required_):
  The generated audio files.
  - Array of File
  - Examples: {"file_size":22069326,"file_name":"sonauto.wav","content_type":"audio/wav","url":"https://cdn.sonauto.ai/generations2_altformats/audio_47337412-e577-42af-ae60-01a798e680ec.wav"}

- **`extend_duration`** (`float`, _required_):
  The duration in seconds that the song was extended by.



**Example Response**:

```json
{
  "seed": 42,
  "audio": {
    "file_size": 22069326,
    "file_name": "sonauto.wav",
    "content_type": "audio/wav",
    "url": "https://cdn.sonauto.ai/generations2_altformats/audio_47337412-e577-42af-ae60-01a798e680ec.wav"
  }
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/sonauto/v2/extend \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "audio_url": "https://cdn.sonauto.ai/generations2_altformats/audio_c5e63f7c-fc79-4322-808d-c09911af4713.wav",
     "side": "left"
   }'
```

### Python

Ensure you have the Python client installed:

```bash
pip install fal-client
```

Then use the API client to make requests:

```python
import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "sonauto/v2/extend",
    arguments={
        "audio_url": "https://cdn.sonauto.ai/generations2_altformats/audio_c5e63f7c-fc79-4322-808d-c09911af4713.wav",
        "side": "left"
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
```

### JavaScript

Ensure you have the JavaScript client installed:

```bash
npm install --save @fal-ai/client
```

Then use the API client to make requests:

```javascript
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("sonauto/v2/extend", {
  input: {
    audio_url: "https://cdn.sonauto.ai/generations2_altformats/audio_c5e63f7c-fc79-4322-808d-c09911af4713.wav",
    side: "left"
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);
```


## Additional Resources

### Documentation

- [Model Playground](https://fal.ai/models/sonauto/v2/extend)
- [API Documentation](https://fal.ai/models/sonauto/v2/extend/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=sonauto/v2/extend)

### fal.ai Platform

- [Platform Documentation](https://docs.fal.ai)
- [Python Client](https://docs.fal.ai/clients/python)
- [JavaScript Client](https://docs.fal.ai/clients/javascript)
