Skip to content

Instantly share code, notes, and snippets.

@hathibelagal-dev
Last active May 20, 2025 23:02
Show Gist options
  • Save hathibelagal-dev/3fee7416b763b067692cb399d7da4f9b to your computer and use it in GitHub Desktop.
Save hathibelagal-dev/3fee7416b763b067692cb399d7da4f9b to your computer and use it in GitHub Desktop.
AceStepLora.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"gpuType": "T4",
"name": "AceStepLora.ipynb",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU"
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/hathibelagal-dev/3fee7416b763b067692cb399d7da4f9b/acestep.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "nUomH0KsYfBe"
},
"outputs": [],
"source": [
"!git clone https://github.com/ace-step/ACE-Step.git\n",
"%cd ACE-Step"
]
},
{
"cell_type": "code",
"source": [
"!pip install -e ."
],
"metadata": {
"id": "Ciob75diYwR0"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"from acestep.pipeline_ace_step import ACEStepPipeline\n",
"from acestep.data_sampler import DataSampler\n",
"import random"
],
"metadata": {
"id": "CDI7uKcIZKui"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"pipe = ACEStepPipeline(\n",
" dtype=\"bfloat16\",\n",
" torch_compile=False,\n",
")"
],
"metadata": {
"id": "RwTpgrmkZX_f"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"song_lyrics = \"\"\"\n",
"别跟我说规则,我走的是野路\n",
"城市是迷宫,我早就不迷路\n",
"说话像刀子,句句都扎心\n",
"我不是明星,我只说真心\n",
"\n",
"梦在夜里燃,现实像冰冷的墙\n",
"我用笔写火,把沉默点亮\n",
"街头的霓虹,照不出希望\n",
"但我步步向前,把命运改装\n",
"\n",
"兄弟还在拼,没人等奇迹\n",
"流汗不喊苦,咬牙也要挺起\n",
"命不是剧本,我自己写戏\n",
"每个失败,都是铺垫的力\n",
"\n",
"副歌:\n",
"风从东方来,节奏不肯停\n",
"龙在天上飞,梦不怕冷清\n",
"心在跳,灯在亮,舞台就此开张\n",
"我在这儿,不退场\n",
"\n",
"第二段:\n",
"命运这张牌,我不靠运气\n",
"靠的是坚持,和不屈的心气\n",
"他们说我疯,我笑着回应\n",
"疯子有梦,才配做传说的原型\n",
"\n",
"爸妈的白发,是我最大的债\n",
"我要让他们老得安心自在\n",
"不是光靠嘴,而是实打实干\n",
"用一砖一瓦,盖出我未来\n",
"\n",
"写词像修剑,每字都带锋芒\n",
"生活再难,我也逆着风狂\n",
"没伞的孩子,也能冲进风浪\n",
"因为我知道,夜深才见光\n",
"\n",
"副歌:\n",
"风从东方来,节奏不肯停\n",
"龙在天上飞,梦不怕冷清\n",
"心在跳,灯在亮,舞台就此开张\n",
"我在这儿,不退场\n",
"\"\"\"\n",
"\n",
"prompt = \"\"\"\n",
"G-Funk, Hip Hop, Rap, Female Vocals, Melodic Rap, Summer, Laid-back Groove, Smooth Rhythm, Synthesizer Lead, Heavy Bassline, Groovy, West Coast Hip Hop\n",
"\"\"\""
],
"metadata": {
"id": "7sAkOpUx1G4y"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"pipe.load_lora(\"ACE-Step/ACE-Step-v1-chinese-rap-LoRA\", 1.0)"
],
"metadata": {
"id": "zicKwOsI0mnr"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"seed = random.randint(1, 4294967295)\n",
"print(seed)"
],
"metadata": {
"id": "B4IAgmhIdyik"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"json_data = {\n",
" \"prompt\": prompt,\n",
" \"lyrics\": song_lyrics,\n",
" \"audio_duration\": 105,\n",
" \"infer_step\": 60,\n",
" \"guidance_scale\": 15,\n",
" \"scheduler_type\": \"euler\",\n",
" \"cfg_type\": \"apg\",\n",
" \"omega_scale\": 10,\n",
" \"guidance_interval\": 0.5,\n",
" \"guidance_interval_decay\": 0,\n",
" \"min_guidance_scale\": 3,\n",
" \"use_erg_tag\": True,\n",
" \"use_erg_lyric\": True,\n",
" \"use_erg_diffusion\": True,\n",
" \"oss_steps\": [],\n",
" \"actual_seeds\": [\n",
" seed\n",
" ]\n",
"}"
],
"metadata": {
"id": "T2qSZepsZvBN"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"def sample_data(json_data):\n",
" return (\n",
" json_data[\"audio_duration\"],\n",
" json_data[\"prompt\"],\n",
" json_data[\"lyrics\"],\n",
" json_data[\"infer_step\"],\n",
" json_data[\"guidance_scale\"],\n",
" json_data[\"scheduler_type\"],\n",
" json_data[\"cfg_type\"],\n",
" json_data[\"omega_scale\"],\n",
" \", \".join(map(str, json_data[\"actual_seeds\"])),\n",
" json_data[\"guidance_interval\"],\n",
" json_data[\"guidance_interval_decay\"],\n",
" json_data[\"min_guidance_scale\"],\n",
" json_data[\"use_erg_tag\"],\n",
" json_data[\"use_erg_lyric\"],\n",
" json_data[\"use_erg_diffusion\"],\n",
" \", \".join(map(str, json_data[\"oss_steps\"])),\n",
" json_data[\"guidance_scale_text\"] if \"guidance_scale_text\" in json_data else 0.0,\n",
" (\n",
" json_data[\"guidance_scale_lyric\"]\n",
" if \"guidance_scale_lyric\" in json_data\n",
" else 0.0\n",
" ),\n",
" )"
],
"metadata": {
"id": "OGfWMdi8Z2FO"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"json_data = sample_data(json_data)\n",
"print(json_data)"
],
"metadata": {
"id": "YUI6E3M7Z-5C"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"(\n",
" audio_duration,\n",
" prompt,\n",
" lyrics,\n",
" infer_step,\n",
" guidance_scale,\n",
" scheduler_type,\n",
" cfg_type,\n",
" omega_scale,\n",
" manual_seeds,\n",
" guidance_interval,\n",
" guidance_interval_decay,\n",
" min_guidance_scale,\n",
" use_erg_tag,\n",
" use_erg_lyric,\n",
" use_erg_diffusion,\n",
" oss_steps,\n",
" guidance_scale_text,\n",
" guidance_scale_lyric,\n",
") = json_data\n",
"\n",
"pipe(\n",
" format=\"wav\",\n",
" audio_duration=audio_duration,\n",
" prompt=prompt,\n",
" lyrics=lyrics,\n",
" infer_step=infer_step,\n",
" guidance_scale=guidance_scale,\n",
" scheduler_type=scheduler_type,\n",
" cfg_type=cfg_type,\n",
" omega_scale=omega_scale,\n",
" manual_seeds=manual_seeds,\n",
" guidance_interval=guidance_interval,\n",
" guidance_interval_decay=guidance_interval_decay,\n",
" min_guidance_scale=min_guidance_scale,\n",
" use_erg_tag=use_erg_tag,\n",
" use_erg_lyric=use_erg_lyric,\n",
" use_erg_diffusion=use_erg_diffusion,\n",
" oss_steps=oss_steps,\n",
" guidance_scale_text=guidance_scale_text,\n",
" guidance_scale_lyric=guidance_scale_lyric,\n",
" save_path=\"./t.wav\",\n",
")"
],
"metadata": {
"id": "73Y7BlZSaFW0"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"from IPython.display import display, Audio\n",
"display(Audio(\"t.wav\"))"
],
"metadata": {
"id": "-qBb8D3Taq6l"
},
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment