liveBook · Manning

TranscriptionModel

As explained in Spring AI in Action

TranscriptionModel is a Spring AI interface for converting audio resources into text.

TranscriptionModel is Spring AI’s abstraction for converting spoken audio into text. Its current implementations target OpenAI and Azure OpenAI, and its transcription operation accepts a Resource and returns a String. section 8.1.1

Use the interface within a voice service:

  • Inject an OpenAiAudioTranscriptionModel into a Spring service. section 8.1.1
  • Pass an uploaded audio Resource to call() and return the resulting transcription. section 8.1.1
  • Forward the transcription into an application operation such as a question-answering service. section 8.1.1

Transcribing an audio question

An /audioAsk endpoint receives an MP3 upload, calls voiceService.transcribe(audioBlob.getResource()), creates a question from the returned text, and sends it to boardGameService.askQuestion(). section 8.1.1

Listing 8.1 Implementing voice transcription
package com.example.boardgamebuddy;

import org.springframework.ai.openai.OpenAiAudioTranscriptionModel;
import org.springframework.ai.openai.audio.speech.SpeechModel;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;

@Service
public class OpenAiVoiceService implements VoiceService {

  private final OpenAiAudioTranscriptionModel transcriptionModel;

  public OpenAiVoiceService(
      OpenAiAudioTranscriptionModel transcriptionModel) {
    this.transcriptionModel = transcriptionModel;  #1
  }

  @Override
  public String transcribe(Resource audioFileResource) {
    return transcriptionModel.call(audioFileResource); #2
  }

  @Override
  public Resource textToSpeech(String text) {
    throw new UnsupportedOperationException("Not implemented yet");
  }

}

Inspect the concrete OpenAI service implementation, including constructor injection and the transcription call. section 8.1.1

How Spring AI in Action covers it

How deep it goes
Explains the interface contract, provider implementations, dependency setup, service wiring, and endpoint integration.
Examples
Uses MP3 or WAV uploads and an audio question endpoint in Board Game Buddy.
What it assumes
Assumes Spring Boot application wiring and API-key configuration, while showing the required voice-service integration.
What you can do after
Build it by injecting a transcription model and forwarding Resource audio to call().
How it connects
Connects Spring AI transcription with OpenAI, Azure OpenAI, Resource, and VoiceService.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring AI in Action. The section links point to the parts of the book it draws on.