You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 20, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: docs/guides/python/ai-podcast-part-1.mdx
+76-16Lines changed: 76 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ In this first part we'll using the [suno/bark](https://huggingface.co/suno/bark)
30
30
31
31
## Prerequisites
32
32
33
-
-[uv](https://docs.astral.sh/uv/#getting-started) - for simplified dependency management
33
+
-[uv](https://docs.astral.sh/uv/#getting-started) - for Python dependency management
34
34
- The [Nitric CLI](/get-started/installation)
35
35
-_(optional)_ An [AWS](https://aws.amazon.com) account
36
36
@@ -64,6 +64,11 @@ As you may know, Nitric helps with both cloud resource creation and interaction.
64
64
65
65
To achieve this let's create a new python module which defines the resources for this project. We'll create this as `common/resources.py` in our project.
66
66
67
+
```bash
68
+
mkdir common
69
+
touch common/resources.py
70
+
```
71
+
67
72
```python title: common/resources.py
68
73
from nitric.resources import api, bucket, job
69
74
# Our main API for submitting audio generation jobs
@@ -170,7 +175,7 @@ Nitric.run()
170
175
171
176
Ok, now that we have our job defined we need a way to trigger it. We'll create an API that lets us submit text to be converted to audio, using the job we just defined.
172
177
173
-
In the existing API endpoint in `services/api.py` overwrite with the following.
178
+
In the existing `services/api.py`file, overwrite the contents with the following.
174
179
175
180
```python title:services/api.py
176
181
from common.resources import main_api, gen_audio_job
@@ -235,15 +240,25 @@ Now that we have the basic structure of our project set up, we can test it local
235
240
nitric start
236
241
```
237
242
238
-
Once its up and running we can test out our API by running:
243
+
Once its up and running we can test our API with any HTTP Client:
239
244
240
245
```bash
241
246
curl -X POST http://localhost:4001/audio/test -d "Okay this is cool, but let's wait and see what comes next"
242
247
```
243
248
244
-
Or you can use the [nitric dashboard](http://localhost:49152/) to submit the same text.
249
+
<Note>
250
+
If port 4001 is already in use on your machine the port will be different,
251
+
e.g. 4002. You can find the port in the terminal output when you start the
252
+
project.
253
+
</Note>
254
+
255
+
Alternatively, you can use the [nitric dashboard](http://localhost:49152/) to submit the same text.
245
256
246
-
Or you can use your favorite API client to test it out.
alt="screen shot of the local development dashboard"
261
+
/>
247
262
248
263
<Note>
249
264
If you're running without a GPU it can take some time for the audio content to
@@ -252,6 +267,12 @@ Or you can use your favorite API client to test it out.
252
267
253
268
Watch the logs in the terminal where you started the project to see the progress of the audio generation. When it's complete you'll can access it from the `clips` bucket using the local Nitric Dashboard e.g. http://localhost:49152/storage/.
Then we can add an API endpoint to trigger the download job and update the API endpoint to allow selection of models and voice presets.
416
439
417
-
```python
440
+
```python title: services/api.py
418
441
from common.resources import main_api, gen_audio_job, download_audio_model_job
419
442
from nitric.application import Nitric
420
443
from nitric.context import HttpContext
@@ -486,6 +509,10 @@ You should get a similiar result to before. The main difference is that the mode
486
509
487
510
So that the AI workload can use GPUs in the cloud we'll need to make sure it ships with drivers and libraries to support that. We can do this by specifying a custom Dockerfile for our batch service under `torch.dockerfile`.
488
511
512
+
```bash
513
+
touch torch.dockerfile
514
+
```
515
+
489
516
```dockerfile title: torch.dockerfile
490
517
# The python version must match the version in .python-version
491
518
FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim AS builder
alt="screen shot of requesting a G instance quota increase on AWS"
686
+
/>
687
+
688
+
Once you've requested the quota increase it may take time for AWS to approve it.
689
+
690
+
### Deploy the project
691
+
692
+
Once the above is complete, we can deploy the project to the cloud using:
637
693
638
694
```bash
639
695
nitric up
640
696
```
641
697
642
698
<Note>
643
699
The initial deployment may take time due to the size of the python/Nvidia
644
-
driver and CUDA runtime dependencies. Be patient.
700
+
driver and CUDA runtime dependencies.
645
701
</Note>
646
702
647
703
Once the project is deployed you can try out some generation, just like before depending on the hardware you were running on locally you may notice a speed up in generation time.
@@ -653,4 +709,8 @@ Running on g5.xlarge from testing this project will cost ~$0.05/minute of audio
653
709
654
710
</Note>
655
711
712
+
You can see the status of your batch jobs in the [AWS Batch console](console.aws.amazon.com/batch/home) and the model and audio files in the [AWS S3 console](https://s3.console.aws.amazon.com/s3/home).
713
+
714
+
## Next steps
715
+
656
716
In part two of this guide we'll look at adding an LLM agent to our project to automatically generate scripts for our podcasts from small prompts.
0 commit comments