diff --git a/api-reference/sdk/go/api-reference.mdx b/api-reference/sdk/go/api-reference.mdx index bc4c6428..7dddea17 100644 --- a/api-reference/sdk/go/api-reference.mdx +++ b/api-reference/sdk/go/api-reference.mdx @@ -26,7 +26,7 @@ const ( 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 ) ``` @@ -377,10 +377,13 @@ type ASRModel string ```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" @@ -392,6 +395,46 @@ const ( ) ``` + +## 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. + +```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 +} +``` + ## type ASRProgressEvent @@ -631,6 +674,12 @@ type ASRResponse struct { 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"` @@ -766,6 +815,18 @@ result, err := client.ASR.Transcribe(ctx, audio, &fishaudio.TranscribeParams{ 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), + }, +}) +``` + ## type ASRSessionDoneEvent @@ -831,6 +892,26 @@ type ASRSessionStats struct { } ``` + +## 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"` +} +``` + ## type ASRSpeechStartEvent @@ -855,6 +936,28 @@ func (*ASRSpeechStartEvent) EventType() string + +## type ASRTextFormat + +ASRTextFormat chooses how transcribe\-2\-pro writes numbers, dates, times and amounts. + +```go +type ASRTextFormat string +``` + + + +```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" +) +``` + ## type ASRTurnDetection @@ -1773,7 +1876,7 @@ If the connection cannot be opened or the start message cannot be sent, it retur The textChan receives text chunks to synthesize. Close the channel to end streaming. Returns a WebSocketAudioStream that can be iterated for audio chunks. -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, ...\). ## type TrainMode @@ -1801,12 +1904,19 @@ TranscribeParams contains parameters for ASR transcription. 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 } ```