Skip to content

Minh/speech transcription tutorial #1807

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ examples/fine-tuned_qa/local_cache/*

# PyCharm files
.idea/
.cursorignore

# VS Code files
.vscode/
17 changes: 11 additions & 6 deletions authors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
# You can optionally customize how your information shows up cookbook.openai.com over here.
# If your information is not present here, it will be pulled from your GitHub profile.

minh-hoque:
name: "Minhajul Hoque"
website: "https://www.linkedin.com/in/minhajul-hoque-83242b163/"
avatar: "https://avatars.githubusercontent.com/u/84698472?v=4"

shikhar-cyber:
name: "Shikhar Kwatra"
website: "https://www.linkedin.com/in/shikharkwatra/"
Expand Down Expand Up @@ -126,13 +131,13 @@ aaronwilkowitz-openai:
charuj:
name: "Charu Jaiswal"
website: "https://www.linkedin.com/in/charu-j-8a866471"
avatar: "https://avatars.githubusercontent.com/u/18404643?v=4"
avatar: "https://avatars.githubusercontent.com/u/18404643?v=4"

rupert-openai:
name: "Rupert Truman"
website: "https://www.linkedin.com/in/rupert-truman/"
avatar: "https://avatars.githubusercontent.com/u/171234447"

keelan-openai:
name: "Keelan Schule"
website: "https://www.linkedin.com/in/keelanschule/"
Expand Down Expand Up @@ -171,8 +176,8 @@ evanweiss-openai:
girishd:
name: "Girish Dusane"
website: "https://www.linkedin.com/in/girishdusane/"
avatar: "https://avatars.githubusercontent.com/u/272708"
avatar: "https://avatars.githubusercontent.com/u/272708"

lxing-oai:
name: "Luke Xing"
website: "https://www.linkedin.com/in/lukexing/"
Expand Down Expand Up @@ -227,7 +232,7 @@ erickgort:
name: "Erick Gort"
website: "https://www.linkedin.com/in/erick-gort-32ab1678/"
avatar: "https://avatars.githubusercontent.com/u/189261906?v=4"

kylecote-tray:
name: "Kyle Cote"
website: "https://github.com/kylecote-tray"
Expand Down Expand Up @@ -297,7 +302,7 @@ rzhao-openai:
name: "Randy Zhao"
website: "https://www.linkedin.com/in/randy-zhao-27433616b"
avatar: "https://avatars.githubusercontent.com/u/208724779?v=4"

brandonbaker-openai:
name: "Brandon Baker"
website: "https://www.linkedin.com/in/brandonbaker18"
Expand Down
672 changes: 672 additions & 0 deletions examples/Speech_transcription_methods.ipynb

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added examples/imgs/agents_sdk_transcription.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/imgs/realtime_api_transcription.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/imgs/speech-to-text-not-streaming.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/imgs/speech-to-text-streaming.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions examples/mermaid/agents_sdk_transcription.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
```{mermaid}
graph LR
Mic -- "PCM frames" --> VP["VoicePipeline"]
VP -- "VAD & resample" --> Buf["Sentence buffer"]
Buf --> GPT["gpt-4o-transcribe"]
GPT --> Agent["Agent callbacks"]
Agent -- "print / reply" --> App
```
13 changes: 13 additions & 0 deletions examples/mermaid/realtime_api_transcription.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
```mermaid
sequenceDiagram
participant Mic
participant App
participant WS as "WebSocket"
participant OAI as "Realtime Server"

Mic ->> App: 20–40 ms PCM frames
App ->> WS: Base64-encoded chunks<br/>input_audio_buffer.append
WS ->> OAI: Audio stream
OAI -->> WS: JSON transcription events<br/>(partial & complete)
WS -->> App: Transcript updates
```
7 changes: 7 additions & 0 deletions examples/mermaid/speech-to-text-not-streaming.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```mermaid
flowchart LR
AudioFile["Audio file<br/>(WAV • MP3 • FLAC)"] --> Upload["Binary upload"]
Upload --> API["/v1/audio/transcriptions"]
API --> JSONOutput["JSON transcription<br/>+ metadata"]
JSONOutput --> App["Your application"]
```
9 changes: 9 additions & 0 deletions examples/mermaid/speech-to-text-streaming.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
```mermaid
flowchart LR
A["Finished audio file<br/>(WAV • MP3 • FLAC • …)"]
B["OpenAI STT engine<br/>(gpt-4o-transcribe)"]
C["Your application / UI"]

A -->|HTTP POST<br/>/v1/audio/transcriptions<br/>stream=true| B
B -->|chunked HTTP response<br/>partial & final transcripts| C
```
10 changes: 10 additions & 0 deletions registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
# should build pages for, and indicates metadata such as tags, creation date and
# authors for each page.

- title: Comparing Speech-to-Text Methods with the OpenAI API
path: examples/Speech_transcription_methods.ipynb
date: 2025-04-29
authors:
- minh-hoque
tags:
- audio
- speech
- agents-sdk

- title: Practial Guide for Model Selection for Real‑World Use Cases
path: examples/partners/model_selection_guide/model_selection_guide.ipynb
date: 2025-05-05
Expand Down