openai

package
v0.21.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements both voice.STTProvider and voice.TTSProvider using OpenAI's Whisper (transcription) and TTS APIs.

func New

func New(apiKey string) *Client

func NewWithHTTPClient

func NewWithHTTPClient(apiKey, baseURL string, httpClient *http.Client) *Client

NewWithHTTPClient creates a client with a custom HTTP client and base URL (for testing).

func (*Client) Synthesize

func (c *Client) Synthesize(ctx context.Context, text string, voice string) ([]byte, error)

Synthesize converts text to speech using OpenAI's TTS API. Returns OGG/Opus audio bytes suitable for Telegram voice messages.

func (*Client) Transcribe

func (c *Client) Transcribe(ctx context.Context, audio []byte, format string) (string, error)

Transcribe sends audio to OpenAI's Whisper API and returns the transcribed text. The format parameter should be the audio file extension (e.g. "ogg", "mp3", "wav").

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL