bark README

The project's README from github.com/suno-ai/bark. As one markdown file: README.md.

Notice: Bark is Suno's open-source text-to-speech+ model. If you are looking for our text-to-music models, please visit us on our web page and join our community on Discord.

🐶 Bark

Twitter

🔗 Examples • Suno Studio Waitlist • Updates • How to Use • Installation • FAQ



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. The model can also produce nonverbal communications like laughing, sighing and crying. To support the research community, we are providing access to pretrained model checkpoints, which are ready for inference and available for commercial use.

⚠ Disclaimer

Bark was developed for research purposes. It is not a conventional text-to-speech model but instead a fully generative text-to-audio model, which can deviate in unexpected ways from provided prompts. Suno does not take responsibility for any output generated. Use at your own risk, and please act responsibly.

📖 Quick Index

🎧 Demos

Open in Spaces Open on Replicate Open In Colab

🚀 Updates

2023.05.01

2023.04.20

🐍 Usage in Python

🪑 Basics

from bark import SAMPLE_RATE, generate_audio, preload_models
from scipy.io.wavfile import write as write_wav
from IPython.display import Audio

# download and load all models
preload_models()

# generate audio from text
text_prompt = """
     Hello, my name is Suno. And, uh — and I like pizza. [laughs] 
     But I also have other interests such as playing tic tac toe.
"""
audio_array = generate_audio(text_prompt)

# save audio to disk
write_wav("bark_generation.wav", SAMPLE_RATE, audio_array)
  
# play text in notebook
Audio(audio_array, rate=SAMPLE_RATE)

pizza1.webm

🌎 Foreign Language


Bark supports various languages out-of-the-box and automatically determines language from input text. When prompted with code-switched text, Bark will attempt to employ the native accent for the respective languages. English quality is best for the time being, and we expect other languages to further improve with scaling.


text_prompt = """
    추석은 내가 가장 좋아하는 명절이다. 나는 며칠 동안 휴식을 취하고 친구 및 가족과 시간을 보낼 수 있습니다.
"""
audio_array = generate_audio(text_prompt)

suno_korean.webm

Note: since Bark recognizes languages automatically from input text, it is possible to use, for example, a german history prompt with english text. This usually leads to english audio with a german accent.

text_prompt = """
    Der Dreißigjährige Krieg (1618-1648) war ein verheerender Konflikt, der Europa stark geprägt hat.
    This is a beginning of the history. If you want to hear more, please continue.
"""
audio_array = generate_audio(text_prompt)

suno_german_accent.webm

🎶 Music

Bark can generate all types of audio, and, in principle, doesn't see a difference between speech and music. Sometimes Bark chooses to generate text as music, but you can help it out by adding music notes around your lyrics.

text_prompt = """
    ♪ In the jungle, the mighty jungle, the lion barks tonight ♪
"""
audio_array = generate_audio(text_prompt)

lion.webm

🎤 Voice Presets

Bark supports 100+ speaker presets across supported languages. You can browse the library of supported voice presets HERE, or in the code. The community also often shares presets in Discord.

Bark tries to match the tone, pitch, emotion and prosody of a given preset, but does not currently support custom voice cloning. The model also attempts to preserve music, ambient noise, etc.

text_prompt = """
    I have a silky smooth voice, and today I will tell you about 
    the exercise regimen of the common sloth.
"""
audio_array = generate_audio(text_prompt, history_prompt="v2/en_speaker_1")

sloth.webm

📃 Generating Longer Audio

By default, generate_audio works well with around 13 seconds of spoken text. For an example of how to do long-form generation, see 👉 Notebook 👈

Click to toggle example long-form generations (from the example notebook)

dialog.webm

longform_advanced.webm

longform_basic.webm

Command line

python -m bark --text "Hello, my name is Suno." --output_filename "example.wav"

💻 Installation

‼️ CAUTION ‼️ Do NOT use pip install bark. It installs a different package, which is not managed by Suno.

pip install git+https://github.com/suno-ai/bark.git

or

git clone https://github.com/suno-ai/bark
cd bark && pip install . 

🤗 Transformers Usage

Bark is available in the 🤗 Transformers library from version 4.31.0 onwards, requiring minimal dependencies and additional packages. Steps to get started:

  1. First install the 🤗 Transformers library from main:
pip install git+https://github.com/huggingface/transformers.git
  1. Run the following Python code to generate speech samples:
from transformers import AutoProcessor, BarkModel

processor = AutoProcessor.from_pretrained("suno/bark")
model = BarkModel.from_pretrained("suno/bark")

voice_preset = "v2/en_speaker_6"

inputs = processor("Hello, my dog is cute", voice_preset=voice_preset)

audio_array = model.generate(**inputs)
audio_array = audio_array.cpu().numpy().squeeze()
  1. Listen to the audio samples either in an ipynb notebook:
from IPython.display import Audio

sample_rate = model.generation_config.sample_rate
Audio(audio_array, rate=sample_rate)

Or save them as a .wav file using a third-party library, e.g. scipy:

import scipy

sample_rate = model.generation_config.sample_rate
scipy.io.wavfile.write("bark_out.wav", rate=sample_rate, data=audio_array)

For more details on using the Bark model for inference using the 🤗 Transformers library, refer to the Bark docs or the hands-on Google Colab.

🛠️ Hardware and Inference Speed

Bark has been tested and works on both CPU and GPU (pytorch 2.0+, CUDA 11.7 and CUDA 12.0).

On enterprise GPUs and PyTorch nightly, Bark can generate audio in roughly real-time. On older GPUs, default colab, or CPU, inference time might be significantly slower. For older GPUs or CPU you might want to consider using smaller models. Details can be found in out tutorial sections here.

The full version of Bark requires around 12GB of VRAM to hold everything on GPU at the same time. To use a smaller version of the models, which should fit into 8GB VRAM, set the environment flag SUNO_USE_SMALL_MODELS=True.

If you don't have hardware available or if you want to play with bigger versions of our models, you can also sign up for early access to our model playground here.

⚙️ Details

Bark is fully generative text-to-audio model devolved for research and demo purposes. It follows a GPT style architecture similar to AudioLM and Vall-E and a quantized Audio representation from EnCodec. It is not a conventional TTS model, but instead a fully generative text-to-audio model capable of deviating in unexpected ways from any given script. Different to previous approaches, the input text prompt is converted directly to audio without the intermediate use of phonemes. It can therefore generalize to arbitrary instructions beyond speech such as music lyrics, sound effects or other non-speech sounds.

Below is a list of some known non-speech sounds, but we are finding more every day. Please let us know if you find patterns that work particularly well on Discord!

Supported Languages

Language Status
English (en) ✅
German (de) ✅
Spanish (es) ✅
French (fr) ✅
Hindi (hi) ✅
Italian (it) ✅
Japanese (ja) ✅
Korean (ko) ✅
Polish (pl) ✅
Portuguese (pt) ✅
Russian (ru) ✅
Turkish (tr) ✅
Chinese, simplified (zh) ✅

Requests for future language support here or in the #forums channel on Discord.

🙏 Appreciation

© License

Bark is licensed under the MIT License.

📱 Community

🎧 Suno Studio (Early Access)

We’re developing a playground for our models, including Bark.

If you are interested, you can sign up for early access here.

❓ FAQ

How do I specify where models are downloaded and cached?

Bark's generations sometimes differ from my prompts. What's happening?

What voices are supported by Bark?

Why is the output limited to ~13-14 seconds?

How much VRAM do I need?

import os
os.environ["SUNO_OFFLOAD_CPU"] = "True"
os.environ["SUNO_USE_SMALL_MODELS"] = "True"

My generated audio sounds like a 1980s phone call. What's happening?

bark (suno-ai/bark)

Searching Database…

39.3K ·GitHub
这是什么?Bark 是 Suno 推出的基于 Transformer 的文本转音频模型,可以根据文本提示生成逼真的多语言语音,以及音乐、背景噪音和音效。
这是常规的文本转语音模型吗,还是别的什么?它不是常规的文本转语音模型,而是完全生成式的 GPT 风格文本转音频模型,因此可能会以意想不到的方式偏离给定的提示。
我该怎么让它运行起来?你可以通过 Hugging Face Transformers 库(4.31.0 及以上版本)使用 Bark:从 main 分支安装 Transformers,然后运行提供的 Python 代码生成语音样本,并将其保存为音频。
安装时有哪些需要避免的坑?不要运行 'pip install bark',那会安装一个与 Suno 无关的其他包;你需要直接安装本仓库,或者使用 Transformers 库。
它能直接用于生产环境的语音克隆吗?不能,它面向研究和演示用途;内置 100 多种说话人预设,但不支持自定义语音克隆。
它开箱即用支持哪些语言?Bark 会自动检测输入语言,支持英语、德语、西班牙语、法语、印地语、意大利语、日语、韩语、波兰语、葡萄牙语、俄语、土耳其语和简体中文,其中英语目前的质量最好。
Bark 需要多少显存?完整模型需要约 12GB 显存;设置环境变量 SUNO_USE_SMALL_MODELS 可加载较小的版本,约 8GB 显存即可运行;再配合额外设置,可以在低至约 2GB 显存的显卡上运行。
Bark 能生成笑声、叹气等非语音声音吗?可以,在文本提示中直接加入 [laughs]、[sighs]、[gasps] 或 [clears throat] 等提示标记,即可触发非语言声音;如果是歌词,则可以使用音符符号(♪)。
Bark 可以免费用于商业用途吗?可以,自 2023 年 5 月起,Bark 采用 MIT 许可证,可用于商业用途。
为什么我生成的音频听起来失真或质量不高?Bark 是完全从零开始生成音频,并不以录音棚级的语音质量为目标,因此输出效果取决于提示内容,从完美的语音到嘈杂、低保真的结果都有可能。
What are similar projects?csm, dia, DramaBox, ChatTTS, OpenVoice, Speech, fish-speech, OmniVoice
Creator
suno-ai
Size
2.6 MB
Stars
39.3K
Updated
CommitApr 05
Age
3y
Commits · 90 Days