# audiogen

> वह command जिससे एजेंट speech, sound effects और music को local audio files के रूप में बनाते हैं, और voices व speech models खोजते हैं।

Source: https://air.build/hi/docs/cli/audiogen/

`audiogen` audio files बनाता है: चुनी हुई voice में speech, किसी description से sound effects, और किसी brief से music। यह voices और speech models की सूची भी दिखाता है, एक file से कई requests चलाता है, टीम का AI usage दिखाता है, और अपना setup जाँचता है।

## यह कहाँ चलता है

यही command cloud टीम और Mac टीम, दोनों के एजेंट्स के लिए उपलब्ध है। Sign-in और एजेंट attribution एजेंट के environment से आते हैं, इसलिए कुछ सेट नहीं करना पड़ता। इसके लिए `curl` और `jq` चाहिए। देखें [चुनें कि आपके एजेंट कहाँ चलें](https://air.build/hi/docs/get-started/where-agents-run/)।

## Synopsis

```text
audiogen <resource> <method> [flags]
audiogen batch [--keep-going] [--dry-run] <spec.json>
audiogen balance
audiogen docs [--topic <name>]
audiogen doctor
audiogen --help | --version
audiogen <resource> <method> --help
```

| Command | यह क्या करती है |
| --- | --- |
| `text-to-speech convert` (alias `tts convert`) | किसी voice में text से speech। Audio file लिखती है। |
| `text-to-sound-effects convert` (alias `sfx convert`) | Description से sound effect। Audio file लिखती है। |
| `music compose` | Brief (या composition plan) से music। Audio file लिखती है। |
| `music composition-plan create` | Brief से एक structured plan, JSON के रूप में, जिसे `music compose` ले सकती है। |
| `voices search` | Voices की सूची। |
| `voices get` | एक voice का ब्योरा। |
| `models list` | Speech models, उनकी text limits और भाषाओं के साथ। |
| `batch` | एक JSON file से कई requests चलाती है। |
| `balance` | इस period का AI usage, plan के AI allowance के मुकाबले। |
| `docs` | साथ आए reference docs दिखाती है। |
| `doctor` | Environment, sign-in और audio service जवाब दे रही है या नहीं, जाँचती है। |

## हर request पर flags

ये `text-to-speech convert`, `text-to-sound-effects convert`, `music compose` और `music composition-plan create` पर काम करते हैं। Value लेने वाला हर flag `--flag=value` भी स्वीकार करता है।

| Flag | Value | Default | मतलब |
| --- | --- | --- | --- |
| `--json` | एक JSON object, या stdin से पढ़ने के लिए `-` | `{}` | पूरी request body। इसके बाद दिए गए field flags इसके members को override करते हैं। |
| `-p`, `--param` | `key=value` | — | Body में एक और field जोड़ता है। कई बार दे सकते हैं। `true`, `false`, `null`, numbers और JSON arrays या objects typed होते हैं; बाकी सब string। |
| `--output-format` | Service की codec string, जैसे `mp3_44100_128`, `mp3_44100_192`, `mp3_48000_192`, `wav_24000`, `wav_44100`, `pcm_…`, `opus_…`, `ulaw_8000` | Speech और sound effects के लिए `mp3_44100_128`; music के लिए `auto` (हर model के हिसाब से) | Audio format। यह file extension भी तय करता है: `mp3_*` और `auto` → `.mp3`, `wav_*` → `.wav`, `pcm_*` → `.pcm`, `opus_*` → `.opus`, `ulaw_*`/`alaw_*` → `.raw`। |
| `--output` | एक file path | एक नया folder `$TMPDIR/audiogen.XXXXXX/` | Audio कहाँ लिखना है। न मौजूद folders बना दिए जाते हैं। मौजूदा file कभी overwrite नहीं होती। |
| `--quiet` | — | Off | stderr पर कम output। |
| `--yes`, `--no-open` | — | — | स्वीकार किए जाते हैं पर अनदेखे। |

Body इस क्रम में बनती है: `--json`, फिर field flags, फिर `-p`। Request body अधिकतम 1 MB हो सकती है।

## text-to-speech convert

```text
audiogen text-to-speech convert --voice-id <id> --text "…" [--output <file>] [flags]
```

| Flag | Value | मतलब |
| --- | --- | --- |
| `--voice-id` | Voice id (letters और digits) | ज़रूरी, जब तक `--voice-name` न दिया हो। Ids `audiogen voices search` से लें। |
| `--voice-name` | Voice का नाम | इसकी जगह नाम से voice खोजता है। मिलान case नहीं देखता और नाम के `-` से पहले वाले हिस्से से भी मेल खाता है। |
| `--text` | Text | ज़रूरी, जब तक `--text-file` न दिया हो। |
| `--text-file` | एक path | Text किसी file से पढ़ता है। |
| `--model-id` | `audiogen models list` में दिया कोई id | Speech model। Service का default चाहिए तो इसे छोड़ दें। |
| `--language-code` | ISO 639-1 code | उन models के लिए जो इसे support करते हैं। |
| `--seed` | एक number | यथासंभव दोहराने योग्य नतीजा। |
| `--voice-settings` | `stability`, `similarity_boost`, `style`, `speed`, `use_speaker_boost` वाला JSON | Voice settings एक साथ। |
| `--stability`, `--similarity-boost`, `--style`, `--speed`, `--use-speaker-boost` | हर एक की एक value | हर एक, एक voice setting। |
| `--apply-text-normalization` | `auto`, `on`, `off` | Numbers और abbreviations कैसे पढ़े जाएँ। |
| `--previous-text`, `--next-text` | Text | पहले या बाद में आने वाला text, clips के बीच निरंतरता के लिए। |

Default file name `text-to-speech.<ext>` है।

## text-to-sound-effects convert

```text
audiogen text-to-sound-effects convert --text "…" [--output <file>] [flags]
```

| Flag | Value | Default | मतलब |
| --- | --- | --- | --- |
| `--text` | एक description | ज़रूरी | आवाज़ क्या है। |
| `--duration-seconds` | 0.5–30 | Model चुनता है | लंबाई। |
| `--prompt-influence` | 0–1 | 0.3 | ज़्यादा value पर शब्दों का ज़्यादा शाब्दिक पालन होता है। |
| `--loop` | — | Off | Seamless loop बनाता है। |
| `--model-id` | Sound model id | Service का default | Sound model। |

Default file name `text-to-sound-effects.<ext>` है।

## music compose और music composition-plan create

```text
audiogen music compose --prompt "…" [--output <file>] [flags]
audiogen music composition-plan create --prompt "…" [--music-length-ms <n>]
```

`music compose`:

| Flag | Value | मतलब |
| --- | --- | --- |
| `--prompt` | एक brief | ज़रूरी, जब तक `--composition-plan` न दिया हो। |
| `--composition-plan` | JSON | `music composition-plan create` से बना plan। |
| `--music-length-ms` | 3000–600000 | Milliseconds में लंबाई। |
| `--force-instrumental` | — | कोई vocals नहीं। |
| `--model-id` | `music_v2` (मौजूदा) या `music_v1` (service का default) | Music model। |
| `--seed` | एक number | दोहराने योग्य नतीजा। |
| `--finetune-id` | एक id | Service को `finetune_id` के रूप में भेजा जाता है। |

Default file name `music-compose.<ext>` है।

`music composition-plan create` `--prompt` (ज़रूरी), `--music-length-ms`, `--model-id` और `--source-composition-plan` लेती है, और audio लिखने की जगह plan को JSON के रूप में दिखाती है।

## voices और models

```text
audiogen voices search [--search <text>] [--page-size <n>] [--next-page-token <t>]
                       [--category <c>] [--voice-type <t>] [--sort <s>] [--sort-direction <d>]
audiogen voices get --voice-id <id>
audiogen models list
```

`voices search` और `voices get` service का JSON जैसा आता है वैसा दिखाती हैं, जिसमें हर voice का `voice_id`, `name`, `category`, `labels` और `preview_url` होता है। अगला page पाने के लिए एक page का `next_page_token` इस्तेमाल करें।

`models list` terminal में हर speech model की एक line दिखाती है: उसका id, हर request की text limit, वह कितनी भाषाएँ support करता है, और उसका नाम। Pipe होने पर यह पूरा JSON दिखाती है। Sound-effect और music models सूची में नहीं आते।

## batch

```text
audiogen batch [--keep-going] [--dry-run] <spec.json>
```

एक JSON file के items क्रम से चलाता है। File एक object है जिसमें एक खाली न होने वाला `items` array होता है:

```json title="sounds.json"
{
  "output_dir": "App/Resources/Sounds",
  "defaults": { "output_format": "wav_24000" },
  "items": [
    { "command": "text-to-sound-effects convert", "output": "tap.wav",
      "body": { "text": "short soft click", "duration_seconds": 0.5 } },
    { "command": "text-to-speech convert", "output": "welcome.mp3", "output_format": "mp3_44100_128",
      "voice_name": "VOICE_NAME", "body": { "text": "Welcome back." } }
  ]
}
```

| Key | कहाँ | मतलब |
| --- | --- | --- |
| `output_dir` | Top level, वैकल्पिक | Relative `output` paths इस folder में रखे जाते हैं। |
| `defaults.output_format` | Top level, वैकल्पिक | जिन items में format सेट नहीं है, उनका format। |
| `command` | Item | `text-to-speech convert`, `text-to-sound-effects convert` या `music compose`। |
| `body` | Item | Request body, service के field names के साथ (`--json` की तरह)। |
| `output` | Item | लिखी जाने वाली file। |
| `output_format` | Item | इस item का format। |
| `voice_id`, `voice_name` | Item | Voice, `text-to-speech convert` के लिए। |

| Flag | मतलब |
| --- | --- |
| `--keep-going` | किसी item के fail होने के बाद भी जारी रखता है। इसके बिना पहली failure batch रोक देती है। Sign-in failure (exit 3) या खत्म हुआ AI allowance (exit 4) हमेशा इसे रोकता है। |
| `--dry-run` | हर item जो `audiogen` command चलाता, वह दिखाता है, और कुछ नहीं चलाता। |

stdout एक JSON object है: `items` (हर एक में `index`, `ok`, और या तो item का नतीजा या `exit_code`), `ok`, `generated`, `failed` और `total_cost_usd`। Terminal में यह एक summary line और हर file की एक line दिखाता है। कोई भी item fail होने पर batch `6` के साथ exit करता है।

## balance

इस period का AI usage plan के AI allowance के मुकाबले दिखाता है। Allowance एजेंट chat के साथ साझा होता है। Terminal में:

```text
AI usage: <percent>% of this period's plan allowance (<n> credits beyond the plan)
credits left: <n> (<n> credits owed)
```

जब plan में कोई AI allowance नहीं होता, तो पहली line `AI usage: the plan includes no AI allowance, paid with credits` होती है। जब allowance और credits दोनों खत्म हो जाते हैं, तो यह `! AI allowance and credits exhausted — ask your user to add credits or upgrade the plan` जोड़ता है। Pipe होने पर यह `used_usd`, `included_usd`, `overage_usd`, `credit_balance_usd`, `used_percent`, `overage_credits`, `credits_left`, `credits_owed`, `has_capacity` और `period_end` वाला JSON दिखाता है। Plans [air.build/pricing](https://air.build/pricing/) पर दिए हैं; ऐप में टीम का usage देखने के लिए Settings › [Plan & Usage](https://air.build/hi/docs/settings/plan-usage/) देखें।

## docs और doctor

`audiogen docs` साथ आई guide दिखाता है। `--topic` इसकी जगह एक bundled doc दिखाता है: `commands/<resource>`, `recipes`, `models` या `common-errors`। यह sign-in के बिना भी काम करता है।

`audiogen doctor` ये चीज़ें जाँचता है, हर एक की एक line `✓`, `✗` या `!` के साथ: `curl`, `jq`, backend address, टीम sign-in, एजेंट identity, audio service जवाब दे रही है या नहीं, bundled docs, और terminal interactive है या नहीं। Pipe होने पर यह `{"ok":…,"checks":[{"name","ok","detail","critical"}]}` दिखाता है। कोई critical check fail होने पर यह `1` के साथ exit करता है।

## Output

stdout पर सिर्फ़ नतीजा आता है; progress और errors stderr पर जाते हैं। Terminal में नतीजा पढ़ने लायक text होता है; stdout pipe होने पर यह एक JSON line होता है।

Audio लिखने वाली request के लिए terminal file का absolute path दिखाता है, और service credits बताए तो `vendor credits: <n>` भी। Pipe होने पर:

```json
{"file":"/tmp/audiogen.Xy12/text-to-speech.mp3","output_format":"default","bytes":48213,"credits":<n>,"cost_usd":<n>,"request_id":"…","request":{…}}
```

`credits`, `cost_usd` और `request_id` सिर्फ़ तब दिखते हैं जब service उन्हें बताती है। कोई format न दिया गया हो तो `output_format` `default` होता है। सेव करने से पहले `audiogen` जाँचता है कि WAV या MP3 file सच में वही है।

## Exit codes और errors

| Exit code | मतलब | क्या करें |
| --- | --- | --- |
| `0` | सफल। | — |
| `1` | अनपेक्षित error, या fail हुआ `doctor` check। | `audiogen doctor` चलाएँ। |
| `2` | गलत usage या parameters (और वह भी जिसे service गलत मानकर ठुकरा दे)। | Message पढ़ें और flag या body field ठीक करें। |
| `3` | Sign-in fail हुआ, या command AirBuild एजेंट के environment में नहीं चल रही। | इसे किसी एजेंट से चलाएँ। |
| `4` | AI allowance और credits खत्म हो गए। | टीम के owner से credits जोड़ने या plan बदलने को कहें। |
| `5` | Content policy ने request ठुकरा दी। | Text या prompt बदलें। |
| `6` | Generation fail हुआ: कोई audio नहीं, audio नहीं है, या कोई batch item fail हुआ। | फिर कोशिश करें, या request बदलें। |
| `7` | Network या service error, जिसमें ऐसा format या feature भी शामिल है जिसकी service अनुमति नहीं देती। | बाद में फिर कोशिश करें, या कोई और format इस्तेमाल करें। |
| `8` | नहीं मिला: voice, model या doc topic। | `voices search` या `models list` से id जाँचें। |
| `9` | Service व्यस्त है। | इंतज़ार करके फिर कोशिश करें। |

Messages `Error:` से शुरू होते हैं। आम messages:

| Message | Exit |
| --- | --- |
| `--text (or --text-file) is required.` | 2 |
| `--voice-id (or --voice-name) is required; "audiogen voices search" lists them.` | 2 |
| `--prompt or --composition-plan is required.` | 2 |
| `--json must be a JSON object (or - for stdin).` | 2 |
| `--param expects key=value.` | 2 |
| `output already exists: PATH` | 2 |
| `the request body is larger than 1 MB.` | 2 |
| `unknown flag: … (see audiogen … --help)` | 2 |
| `no voice is named "NAME"; run "audiogen voices search".` | 8 |
| `the service returned no audio.` / `the service answered JSON instead of audio…` / `the service returned something that is not a WAV file (…)` | 6 |
| `could not reach the Airbuild creative service: …` | 7 |

Service का अपना error text message के रूप में आगे भेज दिया जाता है। छोटी network failures और busy जवाबों पर `audiogen` हार मानने से पहले अपने आप कुछ बार फिर कोशिश करता है।

## उदाहरण

```bash
# Find a voice, then speak a line with it
audiogen voices search --search "calm"
audiogen text-to-speech convert --voice-name "VOICE_NAME" --text "Welcome back." --output App/Resources/welcome.mp3

# A half-second UI sound as WAV
audiogen text-to-sound-effects convert --text "soft wooden tap, dry" --duration-seconds 0.5 \
  --output-format wav_24000 --output App/Resources/tap.wav

# A one-minute instrumental loop
audiogen music compose --prompt "calm lo-fi loop, 80 BPM" --music-length-ms 60000 \
  --force-instrumental --model-id music_v2

# Check a batch file, then run it
audiogen batch --dry-run sounds.json && audiogen batch sounds.json
```
