Documentation
¶
Index ¶
- func Bool(b bool) *bool
- type APIError
- type AuthenticationError
- type Client
- func (c *Client) CancelJob(ctx context.Context, jobID string) error
- func (c *Client) CheckFailed(ctx context.Context, jobIDs []string) ([]bool, error)
- func (c *Client) CompleteUpload(ctx context.Context, jobID string) error
- func (c *Client) CreateUploadJob(ctx context.Context, fileSize int, opts TranscribeOptions) (*UploadJob, error)
- func (c *Client) DownloadResult(ctx context.Context, downloadURL string) ([]byte, error)
- func (c *Client) GetJobStatus(ctx context.Context, jobID string) (*JobStatus, error)
- func (c *Client) GetTranscript(ctx context.Context, jobID string, outputType OutputType) (*Transcript, error)
- func (c *Client) ListJobs(ctx context.Context, limit int, before string) (*JobList, error)
- func (c *Client) Submit(ctx context.Context, audioPath string, opts TranscribeOptions) (string, error)
- func (c *Client) SubmitBytes(ctx context.Context, data []byte, opts TranscribeOptions) (string, error)
- func (c *Client) SubmitURL(ctx context.Context, audioURL string, opts TranscribeOptions) (string, error)
- func (c *Client) TouchUploadProgress(ctx context.Context, jobID string) error
- func (c *Client) Transcribe(ctx context.Context, audioPath string, opts TranscribeOptions, ...) (*Transcript, error)
- func (c *Client) TranscribeBytes(ctx context.Context, data []byte, opts TranscribeOptions, ...) (*Transcript, error)
- func (c *Client) TranscribeFile(ctx context.Context, path string, opts TranscribeOptions, ...) (*Transcript, error)
- func (c *Client) TranscribeURL(ctx context.Context, audioURL string, opts TranscribeOptions, ...) (*Transcript, error)
- func (c *Client) UploadAudio(ctx context.Context, uploadURL string, data []byte, jobID string) error
- func (c *Client) WaitForResult(ctx context.Context, jobID, downloadURL string, onProgress ProgressFunc) ([]byte, string, error)
- type JobFailedError
- type JobList
- type JobNotFoundError
- type JobStatus
- type JobSummary
- type LanguageSegment
- type OutputType
- type ProcessingTier
- type ProgressEvent
- type ProgressFunc
- type RateLimitError
- type TimeoutError
- type TranscribeOptions
- type Transcript
- type TranscriptResult
- type UploadError
- type UploadJob
- type Utterance
- type Word
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AuthenticationError ¶
type AuthenticationError struct {
// contains filtered or unexported fields
}
type Client ¶
type Client struct {
APIKey string
BaseURL string
// Timeout bounds a whole transcription wait (SSE + polling). Individual
// HTTP calls have their own shorter deadlines.
Timeout time.Duration
HTTP *http.Client
// Multipart prefers S3 multipart uploads and falls back to a single presigned
// PUT if the server has multipart disabled or a multipart upload fails
// mid-flight. Defaults to true (set by NewClient).
Multipart bool
// MaxRetries is the number of extra attempts for a JSON API request that
// fails to connect or returns 429/5xx. Uploads and SSE have their own loops.
MaxRetries int
// RetryBackoff is the first retry delay; it doubles per attempt, capped at 30s.
RetryBackoff time.Duration
}
Client talks to the Speech Revolutions STT API.
func NewClient ¶
NewClient creates a Client. If apiKey is empty, it reads SPEECHREVOLUTIONS_API_KEY from the environment.
func (*Client) CheckFailed ¶
CheckFailed calls POST /api/v1/jobs/check-failed.
func (*Client) CompleteUpload ¶
CompleteUpload calls POST /api/v1/upload/complete.
func (*Client) CreateUploadJob ¶
func (c *Client) CreateUploadJob(ctx context.Context, fileSize int, opts TranscribeOptions) (*UploadJob, error)
CreateUploadJob calls POST /api/v1/upload.
func (*Client) DownloadResult ¶
DownloadResult GETs the result bytes from a download URL.
func (*Client) GetJobStatus ¶
GetJobStatus calls GET /api/v1/jobs/{id} for the current status (and a fresh download URL once the job has completed).
func (*Client) GetTranscript ¶
func (c *Client) GetTranscript(ctx context.Context, jobID string, outputType OutputType) (*Transcript, error)
GetTranscript fetches and parses a completed job's transcript by id. It returns a JobFailedError if the job failed, or an error if it is still processing (poll GetJobStatus for that case). Pass "" for outputType to default to JSON.
func (*Client) ListJobs ¶
ListJobs calls GET /api/v1/jobs — the caller's most-recent jobs, newest first, cursor-paginated. Pass the returned NextBefore as before for the next page; limit <= 0 defaults to 50.
func (*Client) Submit ¶
func (c *Client) Submit(ctx context.Context, audioPath string, opts TranscribeOptions) (string, error)
Submit uploads and enqueues a job, returning its job_id WITHOUT waiting for the result. Collect it later via a webhook (opts.CallbackURL) or by polling GetJobStatus / GetTranscript. Ideal for batch workloads. audioPath may be a local path or an http(s) URL.
func (*Client) SubmitBytes ¶
func (c *Client) SubmitBytes(ctx context.Context, data []byte, opts TranscribeOptions) (string, error)
SubmitBytes is like Submit but accepts raw audio bytes.
func (*Client) SubmitURL ¶
func (c *Client) SubmitURL(ctx context.Context, audioURL string, opts TranscribeOptions) (string, error)
SubmitURL enqueues audio the platform fetches from a public http(s) URL.
func (*Client) TouchUploadProgress ¶
TouchUploadProgress calls POST /api/v1/upload/progress.
func (*Client) Transcribe ¶
func (c *Client) Transcribe(ctx context.Context, audioPath string, opts TranscribeOptions, onProgress ProgressFunc) (*Transcript, error)
Transcribe uploads audio, waits for completion, and returns a Transcript. audioPath may be a local filesystem path or an http(s) URL; a URL is handed to the platform to fetch, so nothing is uploaded from here.
func (*Client) TranscribeBytes ¶
func (c *Client) TranscribeBytes(ctx context.Context, data []byte, opts TranscribeOptions, onProgress ProgressFunc) (*Transcript, error)
TranscribeBytes is like Transcribe but accepts raw audio bytes.
func (*Client) TranscribeFile ¶
func (c *Client) TranscribeFile(ctx context.Context, path string, opts TranscribeOptions, onProgress ProgressFunc) (*Transcript, error)
TranscribeFile is an alias for Transcribe with a local path.
func (*Client) TranscribeURL ¶
func (c *Client) TranscribeURL(ctx context.Context, audioURL string, opts TranscribeOptions, onProgress ProgressFunc) (*Transcript, error)
TranscribeURL transcribes audio the platform fetches from a public http(s) URL, then waits for the result.
func (*Client) UploadAudio ¶
func (c *Client) UploadAudio(ctx context.Context, uploadURL string, data []byte, jobID string) error
UploadAudio streams bytes to the presigned URL, with progress heartbeats.
func (*Client) WaitForResult ¶
func (c *Client) WaitForResult(ctx context.Context, jobID, downloadURL string, onProgress ProgressFunc) ([]byte, string, error)
WaitForResult waits via SSE (with polling fallback) and downloads the result.
type JobFailedError ¶
type JobList ¶
type JobList struct {
Jobs []JobSummary `json:"jobs"`
NextBefore string `json:"next_before,omitempty"`
}
JobList is a page of jobs from GET /api/v1/jobs.
type JobNotFoundError ¶
type JobNotFoundError struct {
// contains filtered or unexported fields
}
type JobStatus ¶
type JobStatus struct {
JobID string `json:"job_id"`
Status string `json:"status"` // "processing" | "completed" | "failed"
DownloadURL string `json:"download_url,omitempty"`
FailedStage string `json:"failed_stage,omitempty"`
Reason string `json:"reason,omitempty"`
}
JobStatus is the result of GET /api/v1/jobs/{id}.
func (JobStatus) IsCompleted ¶
IsCompleted reports whether the job finished successfully.
type JobSummary ¶
JobSummary is one entry in a ListJobs page.
type LanguageSegment ¶
type LanguageSegment struct {
Start float64 `json:"start"`
End float64 `json:"end"`
Language string `json:"language"`
}
LanguageSegment is a contiguous time range spoken in a single detected language.
type OutputType ¶
type OutputType string
OutputType is the transcription result format.
const ( OutputTXT OutputType = "txt" OutputJSON OutputType = "json" OutputSRT OutputType = "srt" OutputVTT OutputType = "vtt" OutputDOCX OutputType = "docx" OutputPDF OutputType = "pdf" )
type ProcessingTier ¶
type ProcessingTier string
ProcessingTier selects pricing / scheduling.
const ( TierStandard ProcessingTier = "standard" TierEconomy ProcessingTier = "economy" )
func Tier ¶
func Tier(t ProcessingTier) *ProcessingTier
Tier returns a pointer to t, for TranscribeOptions.Tier.
type ProgressEvent ¶
type ProgressEvent struct {
Completed *int
Total *int
Step string
ElapsedSeconds float64
Raw map[string]any
}
ProgressEvent is a single progress update.
func (ProgressEvent) Percent ¶
func (e ProgressEvent) Percent() (float64, bool)
Percent returns completion as a 0–100 value, clamped to [0,100]. The second return value is false when it can't be computed yet (Completed or Total is nil, or Total is 0) — treat that as "unknown".
type ProgressFunc ¶
type ProgressFunc func(ProgressEvent)
ProgressFunc is called on each progress event.
type RateLimitError ¶
type RateLimitError struct {
RetryAfter float64
// contains filtered or unexported fields
}
RateLimitError carries the server's Retry-After hint in seconds, when one was sent in delta-seconds form.
type TimeoutError ¶
type TimeoutError struct {
// contains filtered or unexported fields
}
type TranscribeOptions ¶
type TranscribeOptions struct {
OutputType OutputType
WordTimestamps *bool
SpeakerLabels *bool
Diarize *bool // alias for SpeakerLabels
NLTK *bool
Tier *ProcessingTier
CustomVocabulary []string
// CallbackURL, if set, is an http(s) webhook POSTed a signed
// completion/failure notification (X-SR-Signature: sha256=...).
CallbackURL string
// OnUploadProgress, if set, is called with a ProgressEvent (Step == "upload")
// for every byte-level upload update. Read Percent() for a 0–100 value.
OnUploadProgress ProgressFunc
// Progress, when true, renders live single-line progress bars to os.Stderr:
// an "Uploading" byte bar, then a "Transcribing" bar. Off by default. It
// composes with the callbacks — the bars render and your callbacks still fire.
Progress bool
}
type Transcript ¶
type Transcript struct {
JobID string
Content []byte
DownloadURL string
OutputType OutputType
Words []Word
Utterances []Utterance
Languages []LanguageSegment
Raw map[string]any
// contains filtered or unexported fields
}
Transcript is the high-level transcription result.
func (Transcript) Save ¶
func (t Transcript) Save(path string) (string, error)
Save writes the raw result bytes to disk and returns the path written. If path has no file extension, "."+OutputType is appended (e.g. "output" -> "output.json"). The client never writes files on its own — call this.
func (Transcript) Text ¶
func (t Transcript) Text() string
Text returns the full transcript (AssemblyAI / ElevenLabs-style).
func (Transcript) ToDeepgram ¶
func (t Transcript) ToDeepgram() map[string]any
ToDeepgram returns a rough Deepgram pre-recorded response shape.
func (Transcript) ToDict ¶
func (t Transcript) ToDict() map[string]any
ToDict returns an AssemblyAI-inspired normalized map.
func (Transcript) TranscriptText ¶
func (t Transcript) TranscriptText() string
TranscriptText is a Deepgram-compatible alias for Text.
type TranscriptResult ¶
type TranscriptResult = Transcript
TranscriptResult is kept as an alias for backwards compatibility.
type UploadError ¶
type UploadError struct {
// contains filtered or unexported fields
}
type UploadJob ¶
type UploadJob struct {
JobID string
UploadURL string
DownloadURL string
ContentType string
ExpiresIn int
}
UploadJob is the result of POST /api/v1/upload.
type Utterance ¶
type Utterance struct {
Text string `json:"text"`
Speaker string `json:"speaker,omitempty"`
Start *float64 `json:"start,omitempty"`
End *float64 `json:"end,omitempty"`
Words []Word `json:"words"`
}
Utterance is a contiguous speaker turn.
type Word ¶
type Word struct {
Word string `json:"word"`
Start *float64 `json:"start,omitempty"`
End *float64 `json:"end,omitempty"`
Speaker string `json:"speaker,omitempty"`
Confidence *float64 `json:"confidence,omitempty"`
Language string `json:"language,omitempty"`
}
Word is a single transcribed word.