Bark
A text-to-audio model for creating speech snippets and sound effects like laughter and music.
Deploy Bark behind an API endpoint in seconds.
Deploy modelExample usage
This code example shows how to invoke the model using the requests library in Python. The model has one input:
prompt
: Input text provided by the user
The output of the model is a JSON object that contains a key called output
which has the output audio stored as a base64 string.
1import requests
2import os
3
4# Replace the empty string with your model id below
5model_id = ""
6baseten_api_key = os.environ["BASETEN_API_KEY"]
7
8data = {
9 "prompt": "Do not go where the path may lead, go instead where there is no path and leave a trail."
10}
11
12# Call model endpoint
13res = requests.post(
14 f"https://model-{model_id}.api.baseten.co/production/predict",
15 headers={"Authorization": f"Api-Key {baseten_api_key}"},
16 json=data
17)
18
19# Convert the base64 output to an audio file
20res = res.json()
21output = res.get("output")
22base64_to_wav(output, "bark_output.wav")
1{
2 "output": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAA..."
3}