AWS AI Services
AWS offers ready-made AI services that you call like any other API: send an image, some text, a document or audio, and get back labels, sentiment, extracted fields, a translation or speech. You do not need to collect training data or understand machine learning to use them, which makes them the fastest way to add AI to an app.
The main services
| Service | Input → output | Example use |
|---|---|---|
| Amazon Rekognition | Images and video → labels, text in images, faces, unsafe-content flags | Tag product photos in an online shop; moderate uploaded images |
| Amazon Comprehend | Text → language, sentiment, key phrases, entities, personal data (PII) | Find unhappy customer reviews; detect phone numbers in support tickets |
| Amazon Transcribe | Speech audio → text, with timestamps and speaker labels | Subtitle recorded lectures; transcribe call-centre recordings |
| Amazon Polly | Text → lifelike speech audio | Read results or announcements aloud; accessibility features |
| Amazon Translate | Text in one language → another language | Translate shop notices between English and Swahili |
| Amazon Textract | Scanned documents and images → text, forms (key-value pairs), tables | Extract fields from application forms, receipts and IDs |
Language support differs between services and changes over time. For example, Amazon Translate supports Swahili, but not every service supports every African language. Check each service's "supported languages" page before you design around it.
Calling them from Python
All six use the same boto3 pattern: create a client, call one method, read the dictionary that comes back. The outputs below are examples; real labels, scores and wording depend on your input and on model updates.
Rekognition: what is in this photo?
import boto3
rekognition = boto3.client("rekognition")
response = rekognition.detect_labels(
Image={"S3Object": {"Bucket": "kuza-shop-photos", "Name": "products/sneakers-01.jpg"}},
MaxLabels=4,
MinConfidence=80,
)
for label in response["Labels"]:
print(f"{label['Name']}: {label['Confidence']:.1f}%")
The image is read straight from S3, so the caller's role needs s3:GetObject on it as well as rekognition:DetectLabels.
Comprehend: how does this customer feel?
comprehend = boto3.client("comprehend")
review = "Delivery to Westlands was fast and the phone case is excellent!"
result = comprehend.detect_sentiment(Text=review, LanguageCode="en")
print(result["Sentiment"])
print(round(result["SentimentScore"]["Positive"], 3))
The four possible sentiments are POSITIVE, NEGATIVE, NEUTRAL and MIXED, each with a score.
Translate: English to Swahili
translate = boto3.client("translate")
result = translate.translate_text(
Text="Your order has been shipped.",
SourceLanguageCode="en",
TargetLanguageCode="sw",
)
print(result["TranslatedText"])
Machine translation can sound unnatural or miss local phrasing, so have a fluent speaker review anything customers will see.
Textract: read a scanned form
textract = boto3.client("textract")
response = textract.detect_document_text(
Document={"S3Object": {"Bucket": "kuza-forms", "Name": "admissions/form-1042.png"}}
)
lines = [block["Text"] for block in response["Blocks"] if block["BlockType"] == "LINE"]
print(lines[:3])
detect_document_text returns plain lines and words. analyze_document with feature types such as FORMS and TABLES returns key-value pairs and table cells, and analyze_expense is specialised for receipts and invoices. Multi-page PDFs use the asynchronous start_... operations.
Polly and Transcribe
polly = boto3.client("polly")
speech = polly.synthesize_speech(
Text="Your results are ready. Log in to the portal to view them.",
OutputFormat="mp3",
VoiceId="Joanna",
Engine="neural",
)
with open("results-ready.mp3", "wb") as f:
f.write(speech["AudioStream"].read())
transcribe = boto3.client("transcribe")
transcribe.start_transcription_job(
TranscriptionJobName="lecture-week3",
Media={"MediaFileUri": "s3://kuza-lectures/week3.mp3"},
MediaFormat="mp3",
LanguageCode="en-US",
OutputBucketName="kuza-lectures",
)
Polly returns audio immediately. Transcribe works as a job: you start it, then check get_transcription_job until its status is COMPLETED, and the transcript JSON appears in the output bucket. Transcribe can also stream audio for live captions.
Using AI services responsibly
- Privacy: images, voices and documents often contain personal data. Get consent, collect only what you need and follow data protection law, such as Kenya's Data Protection Act, 2019.
- Accuracy: confidence scores are not guarantees. Keep a human in the loop for decisions that affect people, like admissions or loans.
- Faces: facial analysis raises serious fairness and civil-liberty concerns, and AWS has its own usage policies for it. Think carefully before using it at all.
The Bias & Fairness and AI Ethics & Safety pages go deeper.
Pricing
These services charge per unit of work: per image analysed, per character translated or spoken, per minute of audio transcribed, per page of document processed. Some include a free allowance for new customers. Costs are small for experiments but grow quickly when you process thousands of items in a loop, so test on a handful first and check each service's pricing page.
Key points
- AWS AI services are pre-trained APIs: no ML expertise or training data needed.
- Rekognition sees, Comprehend understands text, Transcribe and Polly convert between speech and text, Translate translates, and Textract reads documents.
- All follow the same boto3 pattern of client, call and response dictionary.
- Check language support, keep humans in the loop and protect personal data.
- You pay per image, character, minute or page processed.
Tip: use the ← and → keys to move between pages.
