liveBook · Manning

Speech recognition

As explained in Data Analysis with LLMs

Speech recognition is the automatic conversion of spoken language into a machine-readable representation, commonly text.

Speech recognition converts recorded speech into text, making spoken information searchable and enabling voice-based applications. A practical workflow sends an audio file to Whisper and receives its transcription as text. section 7.2 section 7.2.1

Meeting recordings

Automatically transcribing recorded employee meetings creates text that can be searched for information relevant to a team, without listening to every recording. section 7.2

Listing 7.1 Transcribing audio files to text
import argparse
import openai

client = openai.OpenAI()

def transcribe(audio_path):        #1
    """ Transcribe audio file to text.
    
    Args:
        audio_path: path to audio file.
    
    Returns:
        transcribed text.
    """
    with open(audio_path, 'rb') as audio_file:
        transcription = client.audio.transcriptions.create(
            file=audio_file, model='whisper-1')
        return transcription.text

if __name__ == '__main__':         #2
    
    parser = argparse.ArgumentParser()
    parser.add_argument('audiopath', type=str, help='Path to audio file')
    args = parser.parse_args()

    transcript = transcribe(args.audiopath)
    print(transcript)

This Python program accepts an audio-file path, opens the file in binary-read mode, requests transcription with Whisper, and prints the returned text. section 7.2.2

Short audio transcription

A sample recording produces the transcript: “Two years ago, right here on this spot, I had a recurrent dream, too.” section 7.2.3

How Data Analysis with LLMs covers it

How deep it goes
Explains Whisper’s transcription endpoint, file handling, and returned text, without detailing recognition internals.
Examples
Uses recorded employee meetings and a short sample audio clip to demonstrate searchable and transcribed speech.
What it assumes
Assumes an installed OpenAI Python library and an audio-file path; explains opening sound files in binary-read mode.
What you can do after
Apply transcription through OpenAI’s Python library to turn an audio-file path into printed text.
How it connects
Connects transcription with speech translation, speech generation, and natural-language database queries.

Also explained in

Compare how 6 books explain speech recognition →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Analysis with LLMs. The section links point to the parts of the book it draws on.