---
title: "TIL: Generating WAV Files at a Specific Sample Rate With SoX"
description: sox generates or converts audio to any sample rate, bit depth, and channel count. Create test fixtures that match your API's exact requirements.
canonical: https://lukeocodes.dev/til-sox-sample-rate-wav
type: article
locale: en_GB
published: 2023-06-06T00:00:00.000Z
modified: 2023-06-06T00:00:00.000Z
authors:
  - Luke Oliff
section: TIL
tags:
  - TIL
  - Engineering
feed: https://lukeocodes.dev/rss.xml
search: https://lukeocodes.dev/search.json?q={query}
schema:
  - "@context": https://schema.org
    "@graph":
      - "@type": Organization
        "@id": https://ably.com/#organization
        name: Ably
        url: https://ably.com
      - "@type": WebSite
        "@id": https://lukeocodes.dev/#website
        url: https://lukeocodes.dev
        name: Luke Oliff
        alternateName: lukeocodes
        inLanguage: en
        publisher:
          "@id": https://lukeocodes.dev/authors/luke#person
        description: Personal blog and writing by Luke Oliff — developer relations, voice AI, developer experience.
        potentialAction:
          - "@type": SearchAction
            target:
              "@type": EntryPoint
              urlTemplate: https://lukeocodes.dev/blog/search?q={search_term_string}
            query-input: required name=search_term_string
      - "@type": Person
        "@id": https://lukeocodes.dev/authors/luke#person
        name: Luke Oliff
        url: https://lukeocodes.dev/authors/luke
        description: Staff engineer and Staff Tech Lead for Developer Experience at Ably. Writing about developer relations, AI, and the voice industry, from the UK.
        mainEntityOfPage: https://lukeocodes.dev/authors/luke
        givenName: Luke
        familyName: Oliff
        image: https://lukeocodes.dev/authors/luke.jpg
        jobTitle: Staff Tech Lead, Developer Experience
        worksFor:
          "@id": https://ably.com/#organization
        sameAs:
          - https://www.linkedin.com/in/lukeocodes
          - https://github.com/lukeocodes
          - https://bsky.app/profile/lukeocodes.dev
          - https://x.com/lukeocodes
          - https://hashnode.com/@lukeocodes
          - https://dev.to/lukeocodes
        knowsAbout:
          - Developer Relations
          - Developer Experience
          - Voice AI
          - Text-to-Speech
          - Answer Engine Optimisation
          - Search Engine Optimisation
          - Open Source
          - Developer Tooling
          - API Design
          - Speech-to-Text
          - Voice Agents
          - Community Building
        knowsLanguage:
          - English
        nationality: British
        alumniOf:
          - "@type": Organization
            name: The Open University
  - "@context": https://schema.org
    "@graph":
      - "@type": Organization
        "@id": https://ably.com/#organization
        name: Ably
        url: https://ably.com
      - "@type": Person
        "@id": https://lukeocodes.dev/authors/luke#person
        name: Luke Oliff
        url: https://lukeocodes.dev/authors/luke
        description: Staff engineer and Staff Tech Lead for Developer Experience at Ably. Writing about developer relations, AI, and the voice industry, from the UK.
        mainEntityOfPage: https://lukeocodes.dev/authors/luke
        givenName: Luke
        familyName: Oliff
        image: https://lukeocodes.dev/authors/luke.jpg
        jobTitle: Staff Tech Lead, Developer Experience
        worksFor:
          "@id": https://ably.com/#organization
        sameAs:
          - https://www.linkedin.com/in/lukeocodes
          - https://github.com/lukeocodes
          - https://bsky.app/profile/lukeocodes.dev
          - https://x.com/lukeocodes
          - https://hashnode.com/@lukeocodes
          - https://dev.to/lukeocodes
        knowsAbout:
          - Developer Relations
          - Developer Experience
          - Voice AI
          - Text-to-Speech
          - Answer Engine Optimisation
          - Search Engine Optimisation
          - Open Source
          - Developer Tooling
          - API Design
          - Speech-to-Text
          - Voice Agents
          - Community Building
        knowsLanguage:
          - English
        nationality: British
        alumniOf:
          - "@type": Organization
            name: The Open University
      - "@type": BlogPosting
        "@id": https://lukeocodes.dev/til-sox-sample-rate-wav#article
        headline: "TIL: Generating WAV Files at a Specific Sample Rate With SoX"
        alternativeHeadline: "TIL: Generating WAV Files at a Specific Sample Rate With SoX"
        description: sox generates or converts audio to any sample rate, bit depth, and channel count. Create test fixtures that match your API's exact requirements.
        datePublished: 2023-06-06T00:00:00.000Z
        dateModified: 2023-06-06T00:00:00.000Z
        url: https://lukeocodes.dev/til-sox-sample-rate-wav
        mainEntityOfPage: https://lukeocodes.dev/til-sox-sample-rate-wav
        inLanguage: en
        author:
          - "@id": https://lukeocodes.dev/authors/luke#person
        isPartOf:
          "@id": https://lukeocodes.dev/#website
        keywords: TIL, Engineering
        articleSection: TIL
        abstract: APIs expect audio at specific sample rates. SoX generates test files that match exactly.
        speakable:
          "@type": SpeakableSpecification
          cssSelector:
            - .post-tldr
            - h1
        image: https://lukeocodes.dev/og.png?h=TIL%3A+Generating+WAV+Files+at+a+Specific+Sample+Rate+With+SoX&d=sox+generates+or+converts+audio+to+any+sample+rate%2C+bit+depth%2C+and+channel+count.+Create+test+fixtures+that+match+your+API%27s+exact+requirements.&e=Writing
        wordCount: 131
        timeRequired: PT1M
        publisher:
          "@id": https://ably.com/#organization
      - "@type": BreadcrumbList
        itemListElement:
          - "@type": ListItem
            position: 1
            name: Home
            item: https://lukeocodes.dev
          - "@type": ListItem
            position: 2
            name: Writing
            item: https://lukeocodes.dev/blog
          - "@type": ListItem
            position: 3
            name: "TIL: Generating WAV Files at a Specific Sample Rate With SoX"
            item: https://lukeocodes.dev/til-sox-sample-rate-wav
---

[Luke Oliff.](/)

- [Blog](/blog)
- [CV](/cv)
- [Uses](/uses)
- [User manual](/user-manual)
- [Living with ADHD](/living-and-working-with-adhd)
- [RSS](/rss.xml)

[Luke Oliff · Writing](/blog)

# TIL: Generating WAV Files at a Specific Sample Rate With SoX

Jun 2023 · [TIL](/blog/category/til) · 1 min read · [Luke Oliff](/authors/luke)

APIs expect audio at specific sample rates. SoX generates test files that match exactly.

```bash
sox -n test.wav rate 16000 channels 1 synth sine 440
```

Creates a 440Hz sine wave WAV at 16kHz mono. No microphone needed.

```bash
sox -n test.wav rate 8000 channels 1 synth noise
```

White noise at 8kHz mono. Useful for testing silence detection and voice activity detection.

```bash
sox -n test.wav rate 48000 channels 2 synth sawtooth 220 duration 5
```

A 5 second sawtooth wave at 48kHz stereo. Covers higher sample rate APIs.

### What sample rate do most speech APIs use?

16000 Hz (16kHz) mono is the standard for speech recognition. Some support 8000 Hz for telephony quality.

### Can I convert existing files?

```bash
sox input.mp3 -r 16000 -c 1 output.wav
```

[← Newer: TIL: Parallel Processing in Node.js With worker_threads](/til-worker-threads-nodejs)

[All posts](/blog) →

## Search this site

`GET https://lukeocodes.dev/search.json?q=<words>` returns matching posts as JSON, each with its page URL and its markdown URL. Add `&limit=<1-50>` for more than 10. How it works: [/blog/search](https://lukeocodes.dev/blog/search.md).

```sh
curl "https://lukeocodes.dev/search.json?q=developer+relations"
```

---

© 2026 Luke Oliff. Posts live at the root of this site.

- [GitHub](https://github.com/lukeocodes)
- [LinkedIn](https://www.linkedin.com/in/lukeocodes)
- [X](https://x.com/lukeocodes)
- [Bluesky](https://bsky.app/profile/lukeocodes.dev)
- [Email](mailto:luke@lukeoliff.com)
- [RSS](/rss.xml)

## Cookies

This site sets one analytics cookie, from Google Analytics, and only in a browser that accepts the cookie banner. A client that does not run scripts sets no cookies, so there is nothing to accept or decline here.

[Cookie policy](/cookies)
