This repository packages Bark as a Truss.
Bark is a generative audio model for text-to-speech generation.
First, clone this repository:
git clone https://github.com/basetenlabs/truss-examples/
cd bark-trussBefore deployment:
- Make sure you have a Baseten account and API key.
- Install the latest version of Truss:
pip install --upgrade truss
With bark-truss as your working directory, you can deploy the model with:
truss pushPaste your Baseten API key if prompted.
For more information, see Truss documentation.
Bark takes a string as its input and returns a Base64-encoded WAV audio as output. Bark currently works best for strings resulting in up to 12 seconds of audio, or approximately 20-25 words in English.
Here's an example invocation that decodes and saves the output to a file:
truss predict -d '"Two elevator mechanics discuss everything they hate about escalators"' | python process.pyWith process.py as follows:
import base64
import sys
b64_audio = sys.stdin.read()
wav_file = open("bark_output.wav", "wb")
decode_string = base64.b64decode(b64_audio)
wav_file.write(decode_string)