Chunk decoding in the pth notebook.

This commit is contained in:
laurent 2025-07-03 12:56:00 +02:00
parent dc8bffabe0
commit 0ee2354176

View File

@ -74,15 +74,17 @@
"source": [ "source": [
"print(\"Generating audio...\")\n", "print(\"Generating audio...\")\n",
"\n", "\n",
"# This doesn't do streaming generation,\n", "pcms = []\n",
"result = tts_model.generate([entries], [condition_attributes])\n", "def _on_frame(frame):\n",
" print(\"Step\", len(pcms), end=\"\\r\")\n",
" if (frame != -1).all():\n",
" pcm = tts_model.mimi.decode(frame[:, 1:, :]).cpu().numpy()\n",
" pcms.append(np.clip(pcm[0, 0], -1, 1))\n",
"\n", "\n",
"frames = torch.cat(result.frames, dim=-1)\n", "result = tts_model.generate([entries], [condition_attributes], on_frame=_on_frame)\n",
"audio_tokens = frames[:, tts_model.lm.audio_offset :, tts_model.delay_steps :]\n",
"with torch.no_grad():\n",
" audios = tts_model.mimi.decode(audio_tokens)\n",
"\n", "\n",
"audio = audios[0].cpu().numpy()" "print(\"Done generating.\")\n",
"audio = np.concatenate(pcms, axis=-1)",
] ]
}, },
{ {