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

52 lines
1019 B
Go

package main
import (
"fmt"
"io"
"os"
"time"
"github.com/hanzoai/go-openai-realtime/examples/voice/pcm"
"github.com/faiface/beep"
"github.com/faiface/beep/speaker"
)
func main() {
// Open your PCM16 audio file
file, err := os.Open("../record3/output.pcm")
if err != nil {
fmt.Println("Error opening file:", err)
return
}
defer file.Close()
// Read the entire file into memory
data, err := io.ReadAll(file)
if err != nil {
fmt.Println("Error reading file:", err)
return
}
// Define the format of your PCM data
sampleRate := beep.SampleRate(24000) // 24kHz sample rate
format := beep.Format{
SampleRate: sampleRate,
NumChannels: 1, // Mono audio
Precision: 2, // 16-bit PCM
}
// Initialize the speaker with the format
speaker.Init(sampleRate, sampleRate.N(time.Second/10))
// Create a new PCMStream
stream := pcm.NewPCMStream(data, format)
// Play the stream
done := make(chan bool)
speaker.Play(beep.Seq(stream, beep.Callback(func() {
done <- true
})))
<-done
}