{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from bark.api import generate_audio\n", "from bark.generation import SAMPLE_RATE\n", "text_prompt = \"\"\"\n", " Hello, my name is Suno. And, uh — and I like pizza. [laughs] \n", " But I also have other interests such as playing tic tac toe.\n", "\"\"\"\n", "voice_name = \"speaker_0\" # use your custom voice name here if you have one\n", "audio_array = generate_audio(text_prompt, history_prompt=voice_name)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import Audio\n", "# play audio\n", "Audio(audio_array, rate=SAMPLE_RATE)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from scipy.io.wavfile import write as write_wav\n", "# save audio\n", "filepath = \"/output/audio.wav\" # change this to your desired output path\n", "write_wav(filepath, SAMPLE_RATE, audio_array)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.8" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }