{
  "slug": "sphere-to-wav",
  "name": "gizza-ai/sphere-to-wav",
  "version": "0.1.0",
  "title": "SPHERE to WAV — convert NIST .sph speech files — gizza.ai",
  "description": "Convert a NIST SPHERE (.sph) speech-corpus file to a standard WAV in your browser. Parses the ASCII header, fixes big-endian byte order, expands mu-law and A-law.",
  "tags": [
    "sphere to wav",
    "sph to wav",
    "nist sphere converter",
    "timit wav",
    "sph2pipe alternative",
    "switchboard audio",
    "mu-law to pcm",
    "speech corpus converter"
  ],
  "category": "audio",
  "urls": {
    "page": "https://gizza.ai/tools/sphere-to-wav/",
    "markdown": "https://gizza.ai/tools/sphere-to-wav/index.md",
    "descriptor": "https://gizza.ai/tools/sphere-to-wav/tool.json",
    "deep_link_example": "https://gizza.ai/tools/sphere-to-wav/?input=TklTVF8xQQogICAgMjU2CnNhbXBsZV9yYXRlIC1pIDgwMDAKY2hhbm5lbF9jb3VudCAtaSAxCnNhbXBsZV9uX2J5dGVzIC1pIDIKc2FtcGxlX2J5dGVfZm9ybWF0IC1zMiAxMApzYW1wbGVfY29kaW5nIC1zMyBwY20Kc2FtcGxlX2NvdW50IC1pIDIwCmVuZF9oZWFkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAAAD%2BAd4ShYLgsuTCkTHv8RQQF48YTjRtht0kHRf9Y83%2BrtY%2F0PDRM%3D&input_format=auto&output=data_url&encoding=pcm16&channel=all&container=wav&byte_order=auto&start_sample=0&max_samples=0"
  },
  "cli": "gizza tool sphere-to-wav \"TklTVF8xQQogICAgMjU2CnNhbXBsZV9yYXRlIC1pIDgwMDAKY2hhbm5lbF9jb3VudCAtaSAxCnNhbXBsZV9uX2J5dGVzIC1pIDIKc2FtcGxlX2J5dGVfZm9ybWF0IC1zMiAxMApzYW1wbGVfY29kaW5nIC1zMyBwY20Kc2FtcGxlX2NvdW50IC1pIDIwCmVuZF9oZWFkCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAAAD+Ad4ShYLgsuTCkTHv8RQQF48YTjRtht0kHRf9Y83+rtY/0PDRM=\"",
  "tool": {
    "description": "Convert a NIST SPHERE (.sph) speech-corpus file — TIMIT, Switchboard, Fisher, WSJ, TEDLIUM and friends — into a standard RIFF/WAVE file that any player opens. Paste the .sph bytes as base64, hex, or a data: URI. The ASCII SPHERE header is parsed in full (sample_rate, channel_count, sample_n_bytes, sample_coding, sample_byte_format, sample_count and every other field), big-endian samples are byte-swapped to WAV's little-endian order, and mu-law/A-law corpora are expanded to 16-bit PCM by default (encoding=source keeps the original companding, encoding=ulaw/alaw re-encodes). Pick one side of a two-channel conversation with channel=1|2, downmix with channel=mono, excerpt with start_sample/max_samples, and choose container=wav or container=raw headerless samples. output=info returns the full header field table plus duration and byte order instead of audio. Shorten-compressed payloads (sample_coding pcm,embedded-shorten-vX) are detected and reported, not decoded — decompress those with a desktop converter first.",
    "parameters": {
      "additionalProperties": false,
      "properties": {
        "byte_order": {
          "default": "auto",
          "description": "How to read multi-byte samples. 'auto' (default) follows the header's sample_byte_format ('01' = little-endian, '10' = big-endian) and errors if it is missing or unrecognized. 'little'/'big' override the header — use them when a corpus ships a mislabelled byte order and the converted audio comes out as loud noise.",
          "enum": [
            "auto",
            "little",
            "big"
          ],
          "type": "string"
        },
        "channel": {
          "default": "all",
          "description": "Which channels the output keeps. 'all' (default) keeps every channel interleaved; '1' or '2' keeps one side of a two-channel conversation recording (Switchboard/Fisher style); 'mono' averages all channels into a single downmixed track. '2' errors on a mono file.",
          "enum": [
            "all",
            "1",
            "2",
            "mono"
          ],
          "type": "string"
        },
        "container": {
          "default": "wav",
          "description": "Output container. 'wav' (default) writes a RIFF/WAVE file — a 44-byte header for PCM, or an 18-byte `fmt ` chunk plus a `fact` chunk for mu-law/A-law. 'raw' writes only the interleaved sample bytes with no header, which the 'info' output pairs with a ready-to-run ffmpeg re-import command.",
          "enum": [
            "wav",
            "raw"
          ],
          "type": "string"
        },
        "encoding": {
          "default": "pcm16",
          "description": "Sample encoding of the output. 'pcm16' (default) writes 16-bit signed PCM, expanding mu-law/A-law corpora so every player opens the result. 'source' keeps the file's own encoding and bit depth, fixing only the byte order (and 8-bit PCM's signedness, which WAV requires to be unsigned). 'ulaw'/'alaw' re-encode to 8-bit G.711 companded samples, halving the size of a 16-bit corpus at telephone quality.",
          "enum": [
            "pcm16",
            "source",
            "ulaw",
            "alaw"
          ],
          "type": "string"
        },
        "input": {
          "description": "The .sph file's bytes, pasted as base64 (e.g. the output of `base64 utterance.sph`), as hex, or as a `data:…;base64,…` URI. A NIST SPHERE file starts with the ASCII magic \"NIST_1A\" followed by the header size (usually 1024). Decoded input is capped at 6 MiB.",
          "type": "string"
        },
        "input_format": {
          "default": "auto",
          "description": "How the pasted bytes are encoded. 'auto' (default) treats an all-hex-digit even-length payload as hex and everything else as base64; 'base64' also accepts the URL-safe alphabet and missing padding; 'hex' additionally allows ':' and '-' separators.",
          "enum": [
            "auto",
            "base64",
            "hex"
          ],
          "type": "string"
        },
        "max_samples": {
          "default": 0,
          "description": "How many sample frames to convert, starting at start_sample (default 0 = everything to the end). Use it to excerpt a long conversation recording and stay under the 12 MiB output cap.",
          "minimum": 0,
          "type": "integer"
        },
        "output": {
          "default": "data_url",
          "description": "How the converted audio is returned. 'data_url' (default) = a `data:audio/wav;base64,…` URI you can save or play directly. 'base64' = the audio bytes as plain base64 (pipe through `base64 -d > out.wav`). 'hex' = lowercase unbroken hex, `xxd -r -p` compatible, capped at 4 MiB of audio. 'info' = a report of every SPHERE header field, the derived audio properties, byte order, duration, and what the conversion would produce — no audio bytes.",
          "enum": [
            "data_url",
            "base64",
            "hex",
            "info"
          ],
          "type": "string"
        },
        "start_sample": {
          "default": 0,
          "description": "Zero-based index of the first sample frame to convert (default 0). One frame is one sample per channel, so at 16000 Hz frame 16000 is one second in — multiply seconds by sample_rate to cut a time range. Errors if it is at or past the end of the recording.",
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "input"
      ],
      "type": "object"
    }
  }
}