Basic wrapper over the basic api to write files to disk and whatnot.
β‘β‘ Update: Not enough GPU ram memory? Use --use_smaller_models
it still sounds great.
python bark_speak.py --text_prompt "It is a mistake to think you can solve any major problems just with potatoes."
Loading Bark models...
Models loaded.
Estimated time: 6.00 seconds.
Generating: It is a mistake to think you can solve any major problems just with potatoes.
No speaker. Randomly generating a speaker.
100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 100/100 [00:09<00:00, 10.78it/s]
100%|βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ| 36/36 [00:30<00:00, 1.17it/s]
Saved audio to bark_samples/It_is_a_mistake-history_prompt-None-text_temp-0.7-waveform_temp-0.7-2023-04-20-22.wav
just saw this one-click installer: https://github.com/Fictiverse/bark/releases (can't confirm it works myself)
pip install soundfile
wget https://raw.githubusercontent.com/JonathanFly/bark/main/bark_speak.py
python bark_speak.py --text_prompt "It is a mistake to think you can solve any major problems just with potatoes." --history_prompt en_speaker_3
text_prompts = []
text_prompt = """
In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move.
"""
text_prompts.append(text_prompt)
python bark_speak.py --help
usage: bark_speak.py [-h] [--text_prompt TEXT_PROMPT] [--history_prompt HISTORY_PROMPT] [--text_temp TEXT_TEMP]
[--waveform_temp WAVEFORM_TEMP] [--filename FILENAME] [--output_dir OUTPUT_DIR]
[--list_speakers] [--use_smaller_models]
Generate and save audio.
install this first: pip install soundfile
Example: python bark_speak.py --text_prompt "It is a mistake to think you can solve any major problems just with potatoes." --history_prompt en_speaker_3
options:
-h, --help show this help message and exit
--text_prompt TEXT_PROMPT
Text prompt. If not provided, a set of default prompts will be used defined in this file.
--history_prompt HISTORY_PROMPT
Optional. Choose a speaker from the list of languages: English, German, Spanish, French, Hindi, Italian, Japanese, Korean, Polish, Portuguese, Russian, Turkish, Chinese. Use --list_speakers to see all available options.
--text_temp TEXT_TEMP
Text temperature. Default is 0.7.
--waveform_temp WAVEFORM_TEMP
Waveform temperature. Default is 0.7.
--filename FILENAME Output filename. If not provided, a unique filename will be generated based on the text prompt and other parameters.
--output_dir OUTPUT_DIR
Output directory. Default is 'bark_samples'.
--list_speakers List all preset speaker options instead of generating audio.
--use_smaller_models Use for GPUS with less than 10GB of memory, or for more speed.
Original Bark README:
Examples | Model Card | Playground Waitlist
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 ready for inference.
from bark import SAMPLE_RATE, generate_audio
from IPython.display import Audio
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)
Audio(audio_array, rate=SAMPLE_RATE)
pizza.webm
To save audio_array
as a WAV file:
from scipy.io.wavfile import write as write_wav
write_wav("/path/to/audio.wav", SAMPLE_RATE, audio_array)
Bark supports various languages out-of-the-box and automatically determines language from input text. When prompted with code-switched text, Bark will even attempt to employ the native accent for the respective languages in the same voice.
text_prompt = """
Buenos dΓas Miguel. Tu colega piensa que tu alemΓ‘n es extremadamente malo.
But I suppose your english isn't terrible.
"""
audio_array = generate_audio(text_prompt)
miguel.webm
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
Bark has the capability to fully clone voices - including tone, pitch, emotion and prosody. The model also attempts to preserve music, ambient noise, etc. from input audio. However, to mitigate misuse of this technology, we limit the audio history prompts to a limited set of Suno-provided, fully synthetic options to choose from for each language. Specify following the pattern: {lang_code}_speaker_{number}
.
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="en_speaker_1")
sloth.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.
You can provide certain speaker prompts such as NARRATOR, MAN, WOMAN, etc. Please note that these are not always respected, especially if a conflicting audio history prompt is given.
text_prompt = """
WOMAN: I would like an oatmilk latte please.
MAN: Wow, that's expensive!
"""
audio_array = generate_audio(text_prompt)
latte.webm
pip install git+https://github.com/suno-ai/bark.git
or
git clone https://github.com/suno-ai/bark
cd bark && pip install .
Bark has been tested and works on both CPU and GPU (pytorch 2.0+
, CUDA 11.7 and CUDA 12.0).
Running Bark requires running >100M parameter transformer models.
On modern GPUs and PyTorch nightly, Bark can generate audio in roughly realtime. On older GPUs, default colab, or CPU, inference time might be 10-100x slower.
If you don't have new 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.
Similar to Vall-E and some other amazing work in the field, Bark uses GPT-style models to generate audio from scratch. Different from Vall-E, the initial text prompt is embedded into high-level semantic tokens without the use of phonemes. It can therefore generalize to arbitrary instructions beyond speech that occur in the training data, such as music lyrics, sound effects or other non-speech sounds. A subsequent second model is used to convert the generated semantic tokens into audio codec tokens to generate the full waveform. To enable the community to use Bark via public code we used the fantastic EnCodec codec from Facebook to act as an audio representation.
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!
[laughter]
[laughs]
[sighs]
[music]
[gasps]
[clears throat]
β
or...
for hesitationsβͺ
for song lyrics- capitalization for emphasis of a word
MAN/WOMAN:
for bias towards speaker
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) | β |
Arabic | Coming soon! |
Bengali | Coming soon! |
Telugu | Coming soon! |
- nanoGPT for a dead-simple and blazing fast implementation of GPT-style models
- EnCodec for a state-of-the-art implementation of a fantastic audio codec
- AudioLM for very related training and inference code
- Vall-E, AudioLM and many other ground-breaking papers that enabled the development of Bark
Bark is licensed under a non-commercial license: CC-BY 4.0 NC. The Suno models themselves may be used commercially. However, this version of Bark uses EnCodec
as a neural codec backend, which is licensed under a non-commercial license.
Please contact us at bark@suno.ai
if you need access to a larger version of the model and/or a version of the model you can use commercially.
Weβre developing a playground for our models, including Bark.
If you are interested, you can sign up for early access here.