import os os.environ["SUNO_USE_SMALL_MODELS"] = "True" os.environ["SUNO_OFFLOAD_CPU"] = "True" 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 = """ Of course! Here is our menu. We have a wide variety of authentic Chinese dishes to choose from. """ import torch with torch.no_grad(): audio_array = generate_audio(text_prompt, history_prompt="v2/en_speaker_1") # save audio to disk write_wav("bark_generation.wav", SAMPLE_RATE, audio_array) # play text in notebook Audio(audio_array, rate=SAMPLE_RATE)