Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 116 additions & 6 deletions api-reference/sdk/go/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@



# fishaudio

Check warning on line 9 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'fishaudio'?

```go
import "github.com/fishaudio/fish-audio-go"
Expand All @@ -26,7 +26,7 @@
DefaultTimeout = 240 * time.Second

// Version is the SDK version.
Version = "1.3.1" // x-release-please-version
Version = "1.3.2" // x-release-please-version
)
```

Expand All @@ -40,9 +40,9 @@
Bool returns a pointer to v. Optional boolean settings are pointers so that "not set" \(nil, the server default applies\) differs from false.

<a name="APIError"></a>
## type APIError

Check warning on line 43 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'APIError'?

APIError is raised when the API returns an error response.

Check warning on line 45 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'APIError'?

```go
type APIError struct {
Expand Down Expand Up @@ -162,9 +162,9 @@


<a name="ASRContext"></a>
## type ASRContext

Check warning on line 165 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRContext'?

ASRContext gives the model context when a session starts.

Check warning on line 167 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRContext'?

```go
type ASRContext struct {
Expand Down Expand Up @@ -326,9 +326,9 @@


<a name="ASREvent"></a>
## type ASREvent

Check warning on line 329 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASREvent'?

ASREvent is a message from the server in a realtime speech\-to\-text session. Use a type switch on the concrete event types:

Check warning on line 331 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASREvent'?

```
switch e := stream.Event().(type) {
Expand All @@ -349,9 +349,9 @@
```

<a name="ASRLimits"></a>
## type ASRLimits

Check warning on line 352 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRLimits'?

ASRLimits are the limits of a session.

Check warning on line 354 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRLimits'?

```go
type ASRLimits struct {
Expand All @@ -365,9 +365,9 @@
```

<a name="ASRModel"></a>
## type ASRModel

Check warning on line 368 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRModel'?

ASRModel specifies a speech\-to\-text model.

Check warning on line 370 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRModel'?

```go
type ASRModel string
Expand All @@ -377,10 +377,13 @@

```go
const (
// ASRModelTranscribe1 is the API's default model for file transcription.
// It is deprecated and retires on 2026-12-31; after that date, the
// ASRModelTranscribe1 is the API's default model for file transcription
// until it is retired on 2026-12-31.
//
// Deprecated: transcribe-1 is retired on 2026-12-31; after that date, the
// requests it serves, including those with no model header, are served by
// transcribe-2-pro.
// transcribe-2-pro. Use ASRModelTranscribe2Pro instead. The string
// "transcribe-1" passed directly gets no compile-time notice.
ASRModelTranscribe1 ASRModel = "transcribe-1"
// ASRModelTranscribe1Pro is the Transcribe 1 Pro model for file transcription.
ASRModelTranscribe1Pro ASRModel = "transcribe-1-pro"
Expand All @@ -392,6 +395,46 @@
)
```

<a name="ASRProOptions"></a>
## type ASRProOptions

ASRProOptions are the request options of the Pro models \(transcribe\-1\-pro and transcribe\-2\-pro\); TextFormat, Verbatim and Keyterms are for transcribe\-2\-pro only. Other models ignore the options they do not use. An option left at its zero value is not sent, and the API's default applies.

Check warning on line 401 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'Keyterms'?

```go
type ASRProOptions struct {
// Diarize controls speaker identification: the "<|speaker:N|>" markers
// in Text and SpeakerTurns. Default (nil): on. Bool(false) removes both;
// the rest of the transcript does not change.
Diarize *bool
// TagAudioEvents controls sound and emotion tags such as "[laughter]" in
// Text and SpeakerTurns. Default (nil): on. Bool(false) removes them.
TagAudioEvents *bool
// NumSpeakers is the expected number of speakers, a best-effort hint.
// It cannot be combined with MinSpeakers or MaxSpeakers, nor with
// Diarize set to Bool(false). 0 sends nothing.
NumSpeakers int
// MinSpeakers and MaxSpeakers bound the number of speakers, a best-effort
// hint. Either may be given alone, or both with MinSpeakers <=
// MaxSpeakers; neither may be combined with NumSpeakers, nor with
// Diarize set to Bool(false). 0 sends nothing.
MinSpeakers int
MaxSpeakers int
// TextFormat chooses how numbers, dates, times and amounts are written
// (transcribe-2-pro only). Empty: the API's default, ASRTextFormatWritten.
// With Keyterms set, ASRTextFormatSpoken is not always followed.
TextFormat ASRTextFormat
// Verbatim keeps filler words, stutters and false starts
// (transcribe-2-pro only). Default (nil): kept. Bool(false) leaves them
// out.
Verbatim *bool
// Keyterms are words or short phrases likely to be spoken, such as names
// and products, to spell as listed (transcribe-2-pro only): up to 128,
// each without an ASCII comma. Each term is sent as its own form field,
// in order.
Keyterms []string
}
```

<a name="ASRProgressEvent"></a>
## type ASRProgressEvent

Expand Down Expand Up @@ -425,7 +468,7 @@
// Message is a short English description, for humans.
Message string
// ErrorType is the server's error type, such as "invalid_config",
// "idle_timeout" or "server_restarting". Empty when the connection closed

Check warning on line 471 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

'server_restarting' looks like code; format it as code.
// without an error message.
ErrorType string
// Code is the HTTP-style status of the server's error message, or 0.
Expand Down Expand Up @@ -489,7 +532,7 @@

Iterate it with Next, Event and Err from one goroutine. The control methods \(Finalize, AgentSpeaking, AddContext, ReplaceContext, Configure, Keepalive\) and Close are safe to call from any goroutine.

A control message applies at its position in the audio stream: it is sent after every chunk the session has already taken from the audio channel, and before the chunks still waiting in it, because a waiting control message is always picked before more audio. With an unbuffered channel, a chunk is taken when your send on the channel returns, so Finalize called after that send follows the chunk. A chunk offered at the very moment of the call may land on either side.

Check warning on line 535 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'unbuffered'?

The stream ends when the server sends ASRSessionDoneEvent \(after the audio channel is closed\), when the session fails, when ctx is canceled, or when Close is called. The connection is closed by then, whichever it was. When the session ends on this side, the SDK first offers the server a close frame, for at most 250 ms if the server has stopped reading; when the server sent the close frame, the reply to it takes at most 1 s.

Expand Down Expand Up @@ -619,9 +662,9 @@
ReplaceContext drops the items added before with AddContext or ReplaceContext, then adds items.

<a name="ASRResponse"></a>
## type ASRResponse

Check warning on line 665 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRResponse'?

ASRResponse contains the result of speech\-to\-text transcription.

Check warning on line 667 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRResponse'?

```go
type ASRResponse struct {
Expand All @@ -631,6 +674,12 @@
Duration float64 `json:"duration"`
// Segments contains timestamped text segments.
Segments []ASRSegment `json:"segments"`
// SpeakerTurns lists who spoke when, in order. The Pro models return it
// when timestamps are included and ASRProOptions.Diarize is not
// Bool(false). SpeakerTurns == nil means the API sent no turns, and a
// non-nil empty slice means it looked for speakers and found no speech;
// re-encoding with encoding/json does not keep that difference.
SpeakerTurns []ASRSpeakerTurn `json:"speaker_turns,omitempty"`
// RequestID identifies this request; quote it when reporting a problem
// with a transcription. Empty if the API did not return one.
RequestID string `json:"request_id,omitempty"`
Expand All @@ -641,9 +690,9 @@
```

<a name="ASRResults"></a>
## type ASRResults

Check warning on line 693 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRResults'?

ASRResults selects what the server sends back. A nil field is left out, so the server default \(in ASRRealtimeParams\) or the current value \(in ASRConfigureParams\) applies.

Check warning on line 695 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRResults'?

```go
type ASRResults struct {
Expand All @@ -667,9 +716,9 @@
```

<a name="ASRSegment"></a>
## type ASRSegment

Check warning on line 719 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRSegment'?

ASRSegment represents a timestamped segment of transcribed text.

Check warning on line 721 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRSegment'?

```go
type ASRSegment struct {
Expand All @@ -683,9 +732,9 @@
```

<a name="ASRService"></a>
## type ASRService

Check warning on line 735 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRService'?

ASRService provides speech\-to\-text operations.

Check warning on line 737 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRService'?

```go
type ASRService struct {
Expand Down Expand Up @@ -766,6 +815,18 @@
fmt.Println(result.Text)
```

A plain transcript on transcribe\-2\-pro, without speaker markers or sound tags:

```
result, err := client.ASR.Transcribe(ctx, audio, &fishaudio.TranscribeParams{
Model: fishaudio.ASRModelTranscribe2Pro,
Pro: &fishaudio.ASRProOptions{
Diarize: fishaudio.Bool(false),
TagAudioEvents: fishaudio.Bool(false),
},
})
```

<a name="ASRSessionDoneEvent"></a>
## type ASRSessionDoneEvent

Expand Down Expand Up @@ -831,6 +892,26 @@
}
```

<a name="ASRSpeakerTurn"></a>
## type ASRSpeakerTurn

ASRSpeakerTurn is one turn of one speaker in a Pro model transcript.

```go
type ASRSpeakerTurn struct {
// Speaker is the label "speaker:N", where N matches the "<|speaker:N|>"
// marker in the transcript. Labels hold within one response only.
Speaker string `json:"speaker"`
// Text is the turn's speech without speaker markers. It keeps sound
// tags such as "[laughter]" unless ASRProOptions.TagAudioEvents is Bool(false).
Text string `json:"text"`
// Start is the turn start time in seconds.
Start float64 `json:"start"`
// End is the turn end time in seconds.
End float64 `json:"end"`
}
```

<a name="ASRSpeechStartEvent"></a>
## type ASRSpeechStartEvent

Expand All @@ -855,6 +936,28 @@



<a name="ASRTextFormat"></a>
## type ASRTextFormat

ASRTextFormat chooses how transcribe\-2\-pro writes numbers, dates, times and amounts.

```go
type ASRTextFormat string
```

<a name="ASRTextFormatWritten"></a>

```go
const (
// ASRTextFormatWritten writes them in digits and symbols, such as "3:30"
// and "20%". The API's default.
ASRTextFormatWritten ASRTextFormat = "written"
// ASRTextFormatSpoken writes them in words, the way they were said, such
// as "twenty-five dollars".
ASRTextFormatSpoken ASRTextFormat = "spoken"
)
```

<a name="ASRTurnDetection"></a>
## type ASRTurnDetection

Expand Down Expand Up @@ -966,9 +1069,9 @@


<a name="ASRVADEvent"></a>
## type ASRVADEvent

Check warning on line 1072 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRVADEvent'?

ASRVADEvent reports voice activity, sent when Results.VADEvents is on.

Check warning on line 1074 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRVADEvent'?

```go
type ASRVADEvent struct {
Expand All @@ -989,9 +1092,9 @@


<a name="ASRWord"></a>
## type ASRWord

Check warning on line 1095 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRWord'?

ASRWord is one word of a committed transcript, with its timing.

Check warning on line 1097 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'ASRWord'?

```go
type ASRWord struct {
Expand Down Expand Up @@ -1689,9 +1792,9 @@
```

<a name="TTSConfig"></a>
## type TTSConfig

Check warning on line 1795 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'TTSConfig'?

TTSConfig is reusable configuration for text\-to\-speech requests.

Check warning on line 1797 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'TTSConfig'?

```go
type TTSConfig struct {
Expand Down Expand Up @@ -1732,9 +1835,9 @@
```

<a name="TTSService"></a>
## type TTSService

Check warning on line 1838 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'TTSService'?

TTSService provides text\-to\-speech operations.

Check warning on line 1840 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

Did you really mean 'TTSService'?

```go
type TTSService struct {
Expand Down Expand Up @@ -1771,9 +1874,9 @@

If the connection cannot be opened or the start message cannot be sent, it returns a nil stream and the error.

The textChan receives text chunks to synthesize. Close the channel to end streaming. Returns a WebSocketAudioStream that can be iterated for audio chunks.

Check warning on line 1877 in api-reference/sdk/go/api-reference.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

Vale.Spelling

'textChan' looks like code; format it as code.

ctx is passed to the dial, and cancelling it interrupts the start event. It does not end a stream that has started; call Close to stop one.
ctx is passed to the dial, and cancelling it interrupts the start event. It does not end a stream that has started; call Close to stop one. To stop the stream when ctx ends, call Close from context.AfterFunc\(ctx, ...\).

<a name="TrainMode"></a>
## type TrainMode
Expand Down Expand Up @@ -1801,12 +1904,19 @@
type TranscribeParams struct {
// Model is the ASR model, e.g. ASRModelTranscribe2Pro (recommended). It is
// sent as the "model" header. If empty, no header is sent and the request
// runs on the API's default model.
// runs on the API's default model. The default is transcribe-1 until it is
// retired on 2026-12-31. After that date, requests without a model are
// served and billed as transcribe-2-pro, and transcripts can include
// speaker markers and audio-event tags. Set Model, for example to
// ASRModelTranscribe2Pro, to choose the model yourself. The SDK prints no
// warning for an empty Model.
Model ASRModel
// Language is the language code (e.g., "en", "zh"). Auto-detected if empty.
Language string
// IncludeTimestamps indicates whether to include timestamp information. Default: true.
IncludeTimestamps *bool
// Pro holds the options of the Pro models. nil sends none of them.
Pro *ASRProOptions
}
```

Expand Down
Loading