Files
zeekayandHanzo Dev 601155d4d2 refactor(module): declare own import path github.com/hanzoai/go-openai-realtime
Hard-fork of WqyJh/go-openai-realtime (v0.5.x line, commit 3f3cf7a) into the
hanzoai org so the OpenAI/audio-LLM Go stack is fully owned. Renames the module
path across root, contrib/ws-gorilla, and examples, and repoints go-openai from
sashabaranov to github.com/hanzoai/go-openai v1.41.0 (required directly, no
replace directives anywhere).

Co-authored-by: Hanzo Dev <[email protected]>
2026-07-17 22:07:18 -07:00
..
2024-11-04 18:09:54 +08:00

go-openai-realtime example for voice

This is a simple example that demonstrates how to use the go-openai-realtime library to create a voice-to-voice chat program.

Prerequisite

This example needs portaudio library to play audio, please install it before running this library.

On macOS:

brew install pkg-config
brew install portaudio

On Linux:

apt-get install portaudio19-dev

Run

export OPENAI_API_KEY=<your openai api key>
export HTTPS_PROXY=<your socks proxy like: socks5://127.0.0.1:1080> # this optional
go run .

Input start and press enter to start recording, you can say whatever you want. After you finish speaking, input stop and press enter to stop recording. Then a line of text prefixed by [question] will be printed, which is the transcription of your voice. Then, a line of text prefixed by [response] will be printed, which is the response transcription from the server. Meanwhile, you can hear the audio response from the server.

If you want to exit the program, input exit and press enter.

Screenshot:

image