|
88 | 88 | "source": [
|
89 | 89 | "# ─── Standard Library ──────────────────────────────────────────────────────────\n",
|
90 | 90 | "import asyncio\n",
|
| 91 | + "import struct\n", |
91 | 92 | "import base64 # encode raw PCM bytes → base64 before sending JSON\n",
|
92 | 93 | "import json # compose/parse WebSocket messages\n",
|
93 | 94 | "import os\n",
|
|
97 | 98 | "\n",
|
98 | 99 | "# ─── Third-Party ───────────────────────────────────────────────────────────────\n",
|
99 | 100 | "import nest_asyncio\n",
|
100 |
| - "import numpy as np # efficient numeric processing for audio arrays\n", |
| 101 | + "import numpy as np\n", |
101 | 102 | "from openai import OpenAI\n",
|
102 | 103 | "import resampy # high-quality sample-rate conversion\n",
|
103 | 104 | "import soundfile as sf # reads many audio formats into float32 arrays\n",
|
|
110 | 111 | " VoicePipelineConfig,\n",
|
111 | 112 | ")\n",
|
112 | 113 | "from IPython.display import Audio, display\n",
|
113 |
| - "\n", |
114 |
| - "import asyncio, base64, json, time, struct\n", |
115 |
| - "from typing import List\n", |
116 |
| - "\n", |
117 |
| - "import numpy as np, resampy, soundfile as sf, websockets\n", |
118 | 114 | "# ───────────────────────────────────────────────────────────────────────────────\n",
|
119 | 115 | "nest_asyncio.apply()\n",
|
120 | 116 | "\n",
|
|
208 | 204 | },
|
209 | 205 | {
|
210 | 206 | "cell_type": "code",
|
211 |
| - "execution_count": 3, |
| 207 | + "execution_count": null, |
212 | 208 | "id": "7ae4af8d",
|
213 | 209 | "metadata": {},
|
214 | 210 | "outputs": [
|
|
233 | 229 | " response_format='text',\n",
|
234 | 230 | " )\n",
|
235 | 231 | " print('\\n--- TRANSCRIPT ---\\n')\n",
|
236 |
| - " print(transcript)\n" |
| 232 | + " print(transcript)" |
237 | 233 | ]
|
238 | 234 | },
|
239 | 235 | {
|
|
344 | 340 | "\n",
|
345 | 341 | "EV_DELTA = \"conversation.item.input_audio_transcription.delta\"\n",
|
346 | 342 | "EV_DONE = \"conversation.item.input_audio_transcription.completed\"\n",
|
347 |
| - "\n", |
348 |
| - "\n", |
349 | 343 | "# ── helpers ────────────────────────────────────────────────────────────────\n",
|
350 | 344 | "def float_to_16bit_pcm(float32_array):\n",
|
351 | 345 | " clipped = [max(-1.0, min(1.0, x)) for x in float32_array]\n",
|
|
473 | 467 | "transcript"
|
474 | 468 | ]
|
475 | 469 | },
|
476 |
| - { |
477 |
| - "cell_type": "markdown", |
478 |
| - "id": "6b9630f8", |
479 |
| - "metadata": {}, |
480 |
| - "source": [ |
481 |
| - "And lots of times you need to give people more than one link at a time. A band could give their fans a couple new videos from a live concert, a behind the scenes photo gallery, an album to purchase, like these next few links." |
482 |
| - ] |
483 |
| - }, |
484 | 470 | {
|
485 | 471 | "cell_type": "markdown",
|
486 | 472 | "id": "c20826c4",
|
|
652 | 638 | "* Explore the [Agents SDK reference](https://openai.github.io/openai-agents-python/).\n",
|
653 | 639 | "* Explore the [Agents SDK Voice Pipeline reference](https://openai.github.io/openai-agents-python/voice/)"
|
654 | 640 | ]
|
655 |
| - }, |
656 |
| - { |
657 |
| - "cell_type": "markdown", |
658 |
| - "id": "dd511fc0", |
659 |
| - "metadata": {}, |
660 |
| - "source": [] |
661 | 641 | }
|
662 | 642 | ],
|
663 | 643 | "metadata": {
|
|
0 commit comments