The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".
The following errata were submitted by our customers and approved as valid errors by the author or editor.
Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update
| Version |
Location |
Description |
Submitted By |
Date submitted |
Date corrected |
| ePub |
Page page 133
example 3-4 |
Hi,
I have a question how to run the code in Chapter 3.
About the audio models ,examples 3-4 , 3-5 and 3-6.py.
In 3-4.py we have
# schemas.py
from typing import Literal
VoicePresets = Literal["v2/en_speaker_1", "v2/en_speaker_9"]
And
# models.py
import torch
import numpy as np
from transformers import AutoProcessor, AutoModel, BarkProcessor, BarkModel
from schemas import VoicePresets
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
I create from 3-4.py 2 files schemas.py and models.py . Is this the right way to proceed ?
In models.py , there should be from schemas import VoicePresets ;
I proceed the same way in 3-5.py and 3-6.py
To launch the FastAPI app, I do fastapi dev main.py (is that correct ?) but get an import error :"ImportError: cannot import name 'VoicePresets' from 'schemas'
Could you please provide some advice on how to run the code on the githup repo.
Where can I get access to a forum with FAQ for each chapter please?
Note from the Author or Editor: You’re mostly on the right track, but here’s how to fix the ImportError and run the code properly.
You’re seeing:
ImportError: cannot import name 'VoicePresets' from 'schemas'
This is likely because:
Python is importing a different schemas.py (e.g. from another installed package).
Your project structure may not be correct (Python might not find the right schemas.py)
How to Fix
Make sure your directory looks like this:
project/
│
├── main.py
├── models.py
├── schemas.py
├── utils.py
All four files should be in the same folder.
2. Check your import paths
In models.py, this is correct:
from schemas import VoicePresets
As long as schemas.py is in the same folder, that should work.
If it’s in a subfolder like src/schemas.py, then you’d need:
from src.schemas import VoicePresets
Make sure there’s no other schemas.py shadowing it (check for naming conflicts in your virtual environment or system path).
3. You can also try using the following command to start the app
uvicorn main:app --reload
Make sure you’re in the same directory as main.py.
You need to have uvicorn installed:
pip install uvicorn
Optional: Use an __init__.py
To make your directory behave more like a Python module (especially if using subfolders), you can add an empty __init__.py file:
project/
├── __init__.py
├── main.py
├── models.py
├── schemas.py
├── utils.py
About FAQs or forum for the book
The best place to handle FAQs and community questions is to use GitHub Issues or Discussions tab on the repo
|
Anonymous |
Jul 22, 2025 |
|
| Printed |
Page 171
bottom |
A simple regex pattern that captures the URLs into a named group called url and
matches both http and https protocols.
-----------------------------------
Should we revise“url”to urls”
Note from the Author or Editor: Yes, please, should be "urls"
|
Sophia |
Nov 14, 2025 |
|
| Printed |
Page 183
number 4 area |
Instead of returning a chunk, yield it so that the load() function becomes an
asynchronous generator. Asynchronous generators can be iterated with async
for loops so that blocking operations within them can be awaited to let the
event loop start/resume other tasks.
--------------------
"async" and "loops: areis just text, not code, right?
Note from the Author or Editor: "async for" should be code font, but "loops" is regular text.
|
Sophia |
Nov 14, 2025 |
|
| Printed |
Page 428
middle |
For this example, you need to install the pytest-mocks plug-in,
which is a thin wrapper over Python’s built-in mocks library to
simplify mocking implementation. Use the following command to
install pytest-mocks:
--------------------------
Should we revise“pytest-mocks”to “pytest-mock”? Thank you.
Note from the Author or Editor: Yes, please, should be "pytest-mock"
|
Sophia |
Nov 14, 2025 |
|