Skip to content

bentoml/BentoBark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎵 Serving Bark with BentoML

Bark is a transformer-based text-to-audio model created by Suno. Bark can generate highly realistic, multilingual speech as well as other audio - including music, background noise and simple sound effects.

This is a BentoML example project, demonstrating how to build an audio generation API server using Bark. See here for a full list of BentoML example projects.

Prerequisites

  • You have installed Python 3.8+ and pip. See the Python downloads page to learn more.
  • You have a basic understanding of key concepts in BentoML, such as Services. We recommend you read Quickstart first.
  • (Optional) We recommend you create a virtual environment for dependency isolation for this project. See the Conda documentation or the Python documentation for details.

Install dependencies

git clone https://github.com/bentoml/BentoBark.git
cd BentoBark
pip install -r requirements.txt

Run the BentoML Service

We have defined a BentoML Service in service.py. Run bentoml serve in your project directory to start the Service.

$ bentoml serve service:SunoBark

2024-04-03T04:21:20+0000 [WARNING] [cli] Converting 'SunoBark' to lowercase: 'sunobark'.
2024-04-03T04:21:20+0000 [INFO] [cli] Starting production HTTP BentoServer from "service:SunoBark" listening on http://localhost:3000 (Press CTRL+C to quit)

The server is now active at http://localhost:3000. You can interact with it using the Swagger UI or in other different ways. Note that you can set voice_preset to simulate your desired voice. See the Bark Speaker Library for details (use the value in the Prompt Name column).

CURL

curl -X 'POST' \
  'http://localhost:3000/generate' \
  -H 'accept: audio/*' \
  -H 'Content-Type: application/json' \
  -d '{
  "text": "♪ In the jungle, the mighty jungle, the lion barks tonight ♪",
  "voice_preset": null
}'

Python client

import bentoml

with bentoml.SyncHTTPClient("http://localhost:3000") as client:
    result = client.generate(
        text="♪ In the jungle, the mighty jungle, the lion barks tonight ♪",
        voice_preset="",
    )

Expected output:

output-music

Deploy to BentoCloud

After the Service is ready, you can deploy the application to BentoCloud for better management and scalability. Sign up if you haven't got a BentoCloud account.

Make sure you have logged in to BentoCloud, then run the following command to deploy it.

bentoml deploy .

Once the application is up and running on BentoCloud, you can access it via the exposed URL.

Note: For custom deployment in your own infrastructure, use BentoML to generate an OCI-compliant image.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages