bark

The project is compatible with CPU, allowing users running on Mac M1 platform without CUDA accelerating

Preparation

Create a new virtual environment, and activate it

1
2
conda create bark;
conda activate bark

Installment

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

OR

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

Usage

Use package: ipython to key in rows of python commands

Install ipython:

1
pip install ipython

//ipython in wikipedia:
//IPython是一種基於Python的互動式直譯器。相較於原生的Python Shell,IPython提供了更為強大的編輯和互動功能。

Then use ipython to write python sentences:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from bark import SAMPLE_RATE, generate_audio, preload_models
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)

# play text in notebook
Audio(audio_array, rate=SAMPLE_RATE)

This step is to download required models, input text and play text in notebook

1
2
3
from scipy.io.wavfile import write as write_wav

write_wav("/path/to/audio.wav", SAMPLE_RATE, audio_array)

This step is to save the audio as a WAV file, mention that this file is in /path/to directory from above