transcribe

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Initialize

func Initialize(mode TranscriptionMode, config *OpenAIWhisperConfig) error

Initialize initializes the transcription service

func TranscribePCM

func TranscribePCM(samples []int16) error

TranscribePCM transcribes PCM audio data

Types

type MultipartWriter

type MultipartWriter struct {
	*bytes.Buffer
	FormDataContentType string
}

MultipartWriter is a helper to create multipart form data

func NewMultipartWriterWithFile

func NewMultipartWriterWithFile(buffer *bytes.Buffer, fieldName, fileName string, fileData []byte) *MultipartWriter

NewMultipartWriterWithFile creates a new multipart writer with a file

func (*MultipartWriter) Close

func (m *MultipartWriter) Close()

Close finishes the multipart form

func (*MultipartWriter) WriteField

func (m *MultipartWriter) WriteField(fieldName, value string)

WriteField adds a form field to the multipart writer

type OpenAIWhisperClient

type OpenAIWhisperClient struct {
	Config *OpenAIWhisperConfig
	Client *http.Client
}

OpenAIWhisperClient is a client for the OpenAI Whisper API

func NewOpenAIWhisperClient

func NewOpenAIWhisperClient(config *OpenAIWhisperConfig) *OpenAIWhisperClient

NewOpenAIWhisperClient creates a new client for the OpenAI Whisper API

func (*OpenAIWhisperClient) TranscribePCMWithAPI

func (c *OpenAIWhisperClient) TranscribePCMWithAPI(samples []int16) error

TranscribePCMWithAPI transcribes PCM audio using the OpenAI Whisper API

type OpenAIWhisperConfig

type OpenAIWhisperConfig struct {
	APIKey      string
	Model       string
	Language    string
	Temperature float64
	Timeout     time.Duration
}

OpenAIWhisperConfig holds the configuration for the OpenAI Whisper API

func DefaultOpenAIConfig

func DefaultOpenAIConfig() *OpenAIWhisperConfig

DefaultOpenAIConfig returns a default configuration for the OpenAI Whisper API

type TranscriptionMode

type TranscriptionMode string

TranscriptionMode represents the mode of transcription (local or API)

const (
	// LocalMode uses the local Whisper model
	LocalMode TranscriptionMode = "local"
	// APIMode uses the OpenAI Whisper API
	APIMode TranscriptionMode = "api"
)

type WhisperResponse

type WhisperResponse struct {
	Text string `json:"text"`
}

WhisperResponse is the response from the OpenAI Whisper API

Jump to

Keyboard shortcuts

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