Advanced: How to Change the Bit Depth of your Audio File

Introduction

In this example we're going to work through how to change bitdepth of your audio file.

This may be because your specific platform specifies this. If you need other stuff adjusted please reach out to us as support[at]audiostack[dot]ai

What is audio bit depth?

The audio bit depth determines the number of possible amplitude values we can record for each audio sample. The higher the bit depth, the more amplitude values per sample are captured to recreate the original audio signal.

πŸ“˜

CD, mixing standard, Clipped audio

16 is cd standard 24 is mixing standard 32 allows for clipped audio

You may want to vary these depending on the audio you're dealing with

The example

Here is the worked example end to end.


import audiostack
import os

audiostack.api_key = os.environ['AUDIOSTACK_API_KEY']
VOICE="rondala"
advert = (
    "AudioStack's enterprise-grade audio AI technology seamlessly integrates into your product "
    "or workflow and cuts your production cycles to seconds while making your budgets go further. "
    "To find out more about all the cool things you can create using AudioStack, check out our workflow "
    "guides which you can find in the documentation at docs dot audiostack dot com"
)

print("Creating your script from text...")
script = audiostack.Content.Script.create(scriptText=advert)
speech = audiostack.Speech.TTS.create(scriptItem=script, voice=VOICE)
mix = audiostack.Production.Mix.create(speechItem=speech, soundTemplate="pulsing_guitar", masteringPreset="balanced")

encoder = audiostack.Delivery.Encoder.encode_mix(
  productionItem=mix,
  preset="custom",
  sampleRate=44100,
  bitDepth=16,
  channels=2,
  public=True,
  format="wav",
  loudnessPreset="radio"
)
print("downloading")
encoder.download(fileName=f"{script.scriptName}__{VOICE}", path=".")

πŸ“˜

Try other variables

You can try bitDepth in 16,24,or 32. You can also try monochannel by specifying channels=1.