---
name: ground-state-foundry-voice-models
description: Use Ground State Foundry's real-time voice models over a live stream — change an Indian English accent to American or Arabic-accented English in the same voice (Ant Flash), restore phone audio to 48 kHz (Audio Upscaler), or keep only the voice nearest the microphone (Nearfield). Covers signing up by email, getting an API key, checking credit, streaming a WAV file or a microphone, and asking for more credit. Everything works with curl and one Python script.
---

# Ground State Foundry voice models

Real-time speech models, used over a live stream: audio goes in in 100 ms pieces and the model's output comes
back as it is made. Every new account gets **$20 of credit, valid for 90 days**. No dashboard: everything below
is curl and one Python script.

- API: `https://api.groundstatefoundry.com`
- Live streams: `wss://stream.groundstatefoundry.com`
- Client script: `https://groundstatefoundry.com/models/skill/gsf_stream.py`

## Models

| id | what it does | output | price per minute |
|---|---|---|---|
| `antflash-us` | Indian English → American English accent, same voice | 24 kHz | $0.009 |
| `antflash-ar` | Indian English → Arabic-accented English, same voice | 24 kHz | $0.009 |
| `upscaler` | phone-band speech → full-band 48 kHz | 48 kHz | $0.004 |
| `nearfield` | keeps only the voice nearest the microphone; removes other voices and noise | 16 kHz | $0.003 |

Options: `nf` = Nearfield voice isolation before the model (+$0.002/min; Ant Flash and Upscaler), `up` = upscale
Ant Flash's output to 48 kHz (+$0.002/min). Current prices: `curl https://api.groundstatefoundry.com/v1/models`.

Ant Flash learns the speaker's voice from the first 3 seconds of speech, then converts the accent and keeps the
voice. It runs about 0.5 s behind the speaker plus the network; Nearfield and the Upscaler about 0.05 s plus
the network. The models run in Mumbai (AWS ap-south-1).

## 1. Sign up and get a key

```bash
curl -s -X POST https://api.groundstatefoundry.com/v1/signup -H 'content-type: application/json' -d '{"email":"you@company.com"}'
# a 6-digit code arrives by email (valid 15 minutes); ask the user for it
curl -s -X POST https://api.groundstatefoundry.com/v1/signup/verify -H 'content-type: application/json' -d '{"email":"you@company.com","code":"123456"}'
```

The reply has `api_key` (starts with `gsf_`). It is shown once: store it, for example as `GSF_API_KEY` in the
user's environment or secret store, never in code or chat logs. Signing up again with the same email gives a
new key and revokes the old one (that is also how to recover a lost key); it does not add credit.

## 2. Check the account

```bash
curl -s https://api.groundstatefoundry.com/v1/me    -H "Authorization: Bearer $GSF_API_KEY"   # balance, credit expiry, stream cap, streams running
curl -s https://api.groundstatefoundry.com/v1/usage -H "Authorization: Bearer $GSF_API_KEY"   # recent streams: model, seconds, cost
curl -s -X POST https://api.groundstatefoundry.com/v1/keys/rotate -H "Authorization: Bearer $GSF_API_KEY"   # new key, old one stops working
```

## 3. Stream audio

```bash
curl -sO https://groundstatefoundry.com/models/skill/gsf_stream.py      # or use scripts/gsf_stream.py next to this file, if installed as a skill
pip install websockets numpy            # scipy optional (better resampling); sounddevice for --mic
export GSF_API_KEY=gsf_...
python gsf_stream.py --model antflash-us input.wav output.wav           # file, sent at real-time pace
python gsf_stream.py --model antflash-ar --nf --up input.wav output.wav # isolation first, 48 kHz out
python gsf_stream.py --model nearfield --mic output.wav                 # microphone; Ctrl-C to stop
```

Input: any 16-bit PCM WAV (mono or stereo, any rate). A file takes as long as it plays: these are live models.
The script prints how far the output runs behind the input.

### Protocol (to write your own client)

WebSocket `wss://stream.groundstatefoundry.com` with header `Authorization: Bearer <key>`. All messages are JSON text.

1. send `{"action":"start","model":"antflash-us","nf":0,"up":0}`
2. receive `{"t":"status",...}` (a cold start takes a few seconds), then `{"t":"route","worker":"<id>"}` and
   `{"t":"ready","sr":<output rate>,"algo_ms":<model look-ahead>}`, in either order: wait for both
3. send audio, about every 100 ms, in real time: `{"action":"audio","to":"<worker id>","n":<samples sent before this piece>,"pcm":"<base64 int16 little-endian, 16 kHz mono>"}`
4. receive `{"t":"out","pcm":"<base64 int16 at sr>","end":<output samples so far>}` as the model makes it
5. to finish: send about 1 s of silence (so the last words come out), then `{"action":"stop","to":"<worker id>"}`;
   receive `{"t":"end","reason":...}`

Also: `{"action":"ping","ts":x}` → `{"t":"pong","ts":x}`. Sending faster than real time does not speed anything
up; if the input runs more than about 1 s ahead of the model, the oldest audio is dropped.

### Limits and errors

- **Streams at once:** 2 per account by default (ask for more). A third gets `{"t":"error","code":"stream_limit"}`.
- **Length:** one stream lasts up to 14 minutes, then ends with `reason: "max_duration"`; open a new one to carry on
  (the script does this for files). Send audio in real time, silence included: a stream with no audio for 20 s
  ends, and so does one sending under a quarter of real time for 20 s (`reason: "too_little_audio"`).
- **Billing:** per minute the stream is open (from `ready` to the end) or of audio sent, whichever is more,
  taken from the credit that expires first, checked every 10 s. At zero: `{"t":"error","code":"out_of_credit"}`
  and the stream ends.
- **Connect refused:** 401 bad key · 402 no credit left · 403 account disabled · 429 too many requests.
- Other error codes: `bad_model`, `already_started` (one stream per connection), `busy`, `could_not_start`,
  `unauthorized` (the key was replaced or the account disabled since connecting).
- Messages: about 10 a second per stream is normal; well over that is dropped, and a flood closes the connection.

## 4. More credit

```bash
curl -s -X POST https://api.groundstatefoundry.com/v1/credits/request -H "Authorization: Bearer $GSF_API_KEY" \
  -H 'content-type: application/json' -d '{"amount_usd":500,"company":"Acme","note":"PO 1234"}'
```

We reply by email with an invoice; the credit is added once it is paid. For more streams at once, on-premises
deployment or other models: hello@groundstatefoundry.com.

## Privacy

Audio is processed in memory and not stored. We keep, per stream, the model, options, seconds and cost (for
billing) and the account's email.
