liveBook · Manning

Chapter 8: Generating with voice and pictures

What you will learn in chapter 8 of Spring AI in Action

The introduction explains why moving beyond text-only interaction would make Board Game Buddy more natural for people to use.

After this chapter you will be able to

What it builds on

Section by section

Introduction

The introduction explains why moving beyond text-only interaction would make Board Game Buddy more natural for people to use.

Key terms: Board Game Buddy, text-based interaction, voice-based, images

8.1 Working with voice

Introduces voice as a natural way to interact with Spring applications and identifies the two directions of speech generation.

Key terms: audio file, textual representation, spoken audio, voice interaction

8.1.1 Transcribing speech

This section adds speech transcription to Board Game Buddy so a spoken question can be submitted to its existing question-answering service.

Key terms: TranscriptionModel, OpenAiAudioTranscriptionModel, AzureOpenAiAudioTranscriptionModel, autoconfiguration, VoiceService, transcribe(), Resource, call(), OpenAiVoiceService, /audioAsk

8.1.2 Generating speech from text

This section implements text-to-speech in a Spring AI voice service, returns spoken answers through an HTTP endpoint, and shows how to customize speech generation.

Key terms: SpeechModel, textToSpeech(), call(), ByteArrayResource, Resource, audioAskAudioResponse(), BoardGameService, Answer, @PostMapping, produces

8.1.3 Applying audio input and output directly

This section shows how Board Game Buddy can send a spoken question directly to an audio-enabled chat model and return its spoken answer without separate transcription or speech-generation steps.

Key terms: GPT-4o Audio, GPT-4o mini Audio, audio-enabled models, AudioQuestion, Resource, Media, media(), text(), options(), ALLOY

8.2 Asking questions about images

Shows how Board Game Buddy accepts an uploaded image and uses it alongside a question, game rules, and chat history to answer questions about a game.

Key terms: vision, RAG, ChatClient, chat history, askQuestion(), Resource, MimeType, text(), media(), visionAsk()

8.3 Generating images

Shows how to configure Spring AI image generation, return generated images as URLs or bytes, and use it in a burger-art controller.

Key terms: ImageModel, starter dependency, spring.ai.model.image, autoconfiguration, ImageService, ImageOptions, instructions, width, height, url

8.3.1 Specifying image options

This section explains how to choose image-generation options with builders or configuration properties, including OpenAI and Azure OpenAI variants.

Key terms: style(), vivid, natural, hd quality, ImageOptionsBuilder, OpenAiImageOptions, builder(), configuration properties, application.properties, defaults

8.4 Summary

Concepts explained in this chapter

← Chapter 7: Applying Model Context Protocol Chapter 9: Observing AI operations →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.