Documentation
¶
Index ¶
- Constants
- Variables
- func Bool(b bool) param.Opt[bool]
- func BoolPtr(v bool) *bool
- func DefaultClientOptions() []option.RequestOption
- func File(rdr io.Reader, filename string, contentType string) file
- func Float(f float64) param.Opt[float64]
- func FloatPtr(v float64) *float64
- func Int(i int64) param.Opt[int64]
- func IntPtr(v int64) *int64
- func Opt[T comparable](v T) param.Opt[T]
- func Ptr[T any](v T) *T
- func String(s string) param.Opt[string]
- func StringPtr(v string) *string
- func Time(t time.Time) param.Opt[time.Time]
- func TimePtr(v time.Time) *time.Time
- type AccountGetResponse
- type AccountGetResponsePlan
- type AccountGetResponseUsage
- type AccountService
- type Client
- type Error
- type ErrorBody
- type ErrorType
- type LanguageCode
- type Model
- type OutputFormat
- type SampleRate
- type SessionInitFormat
- type SessionInitSampleRate
- type SessionNewParams
- type SessionService
- type SpeechGenerateDetailedParams
- type SpeechGenerateDetailedResponse
- type SpeechGenerateParams
- type SpeechService
- type SpeechSession
- func (s *SpeechSession) Close() error
- func (s *SpeechSession) Messages(ctx context.Context) iter.Seq2[SpeechSessionMessage, error]
- func (s *SpeechSession) Recv(ctx context.Context) (SpeechSessionMessage, error)
- func (s *SpeechSession) RequestID() string
- func (s *SpeechSession) SendFinish(ctx context.Context) error
- func (s *SpeechSession) SendFlush(ctx context.Context) (nonce int64, err error)
- func (s *SpeechSession) SendReset(ctx context.Context) (nonce int64, err error)
- func (s *SpeechSession) SendText(ctx context.Context, text string) error
- func (s *SpeechSession) StreamAudio(ctx context.Context, w io.Writer) error
- type SpeechSessionAudio
- type SpeechSessionError
- type SpeechSessionFlushComplete
- type SpeechSessionMessage
- type SpeechSessionReady
- type SpeechSessionResetComplete
- type SpeechSessionTimestamps
- type Timestamp
- type TimestampObject
- type Voice
- type VoiceDeleteResponse
- type VoiceListParams
- type VoiceNewParams
- type VoiceOwner
- type VoiceService
- func (r *VoiceService) Delete(ctx context.Context, id string, opts ...option.RequestOption) (res *VoiceDeleteResponse, err error)
- func (r *VoiceService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *Voice, err error)
- func (r *VoiceService) List(ctx context.Context, query VoiceListParams, opts ...option.RequestOption) (res *[]Voice, err error)
- func (r *VoiceService) New(ctx context.Context, body VoiceNewParams, opts ...option.RequestOption) (res *Voice, err error)
- func (r *VoiceService) Update(ctx context.Context, id string, body VoiceUpdateParams, ...) (res *VoiceUpdateResponse, err error)
- type VoiceType
- type VoiceUpdateParams
- type VoiceUpdateResponse
Constants ¶
const ( LanguageCodeAuto = shared.LanguageCodeAuto LanguageCodeAr = shared.LanguageCodeAr LanguageCodeAs = shared.LanguageCodeAs LanguageCodeBn = shared.LanguageCodeBn LanguageCodeCs = shared.LanguageCodeCs LanguageCodeDa = shared.LanguageCodeDa LanguageCodeDe = shared.LanguageCodeDe LanguageCodeEn = shared.LanguageCodeEn LanguageCodeEs = shared.LanguageCodeEs LanguageCodeFi = shared.LanguageCodeFi LanguageCodeFr = shared.LanguageCodeFr LanguageCodeHi = shared.LanguageCodeHi LanguageCodeID = shared.LanguageCodeID LanguageCodeIt = shared.LanguageCodeIt LanguageCodeJa = shared.LanguageCodeJa LanguageCodeKo = shared.LanguageCodeKo LanguageCodeMl = shared.LanguageCodeMl LanguageCodeMr = shared.LanguageCodeMr LanguageCodeNl = shared.LanguageCodeNl LanguageCodePl = shared.LanguageCodePl LanguageCodePt = shared.LanguageCodePt LanguageCodeRu = shared.LanguageCodeRu LanguageCodeSk = shared.LanguageCodeSk LanguageCodeSv = shared.LanguageCodeSv LanguageCodeTa = shared.LanguageCodeTa LanguageCodeTe = shared.LanguageCodeTe LanguageCodeTh = shared.LanguageCodeTh LanguageCodeTr = shared.LanguageCodeTr LanguageCodeUk = shared.LanguageCodeUk LanguageCodeUr = shared.LanguageCodeUr LanguageCodeVi = shared.LanguageCodeVi LanguageCodeZh = shared.LanguageCodeZh )
const ( OutputFormatAAC = shared.OutputFormatAAC OutputFormatMP3 = shared.OutputFormatMP3 OutputFormatULaw = shared.OutputFormatULaw OutputFormatWav = shared.OutputFormatWav OutputFormatWebM = shared.OutputFormatWebM OutputFormatPCMS16LE = shared.OutputFormatPCMS16LE OutputFormatPCMF32LE = shared.OutputFormatPCMF32LE )
const ( SampleRate8000 = shared.SampleRate8000 SampleRate16000 = shared.SampleRate16000 SampleRate24000 = shared.SampleRate24000 )
const ErrorTypeAuthenticationError = shared.ErrorTypeAuthenticationError
Equals "authentication_error"
const ErrorTypeInternalServerError = shared.ErrorTypeInternalServerError
Equals "internal_server_error"
const ErrorTypeInvalidRequestError = shared.ErrorTypeInvalidRequestError
Equals "invalid_request_error"
const ErrorTypeNotFoundError = shared.ErrorTypeNotFoundError
Equals "not_found_error"
const ErrorTypePaymentRequiredError = shared.ErrorTypePaymentRequiredError
Equals "payment_required_error"
const ErrorTypePermissionError = shared.ErrorTypePermissionError
Equals "permission_error"
const ErrorTypeRateLimitError = shared.ErrorTypeRateLimitError
Equals "rate_limit_error"
const (
ModelBlizzard = shared.ModelBlizzard
)
Variables ¶
var ErrSessionClosed = errors.New("lmnt speech session: closed")
ErrSessionClosed is the sentinel returned by the Send methods (and by Recv) once the session has been closed locally. Check it with errors.Is.
Functions ¶
func DefaultClientOptions ¶
func DefaultClientOptions() []option.RequestOption
DefaultClientOptions reads from the environment (LMNT_API_KEY, LMNT_BASE_URL) and returns the options applied before any caller-supplied options.
func Opt ¶
func Opt[T comparable](v T) param.Opt[T]
Types ¶
type AccountGetResponse ¶
type AccountGetResponse struct {
Plan AccountGetResponsePlan `json:"plan" api:"required"`
Usage AccountGetResponseUsage `json:"usage" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Plan respjson.Field
Usage respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (AccountGetResponse) RawJSON ¶
func (r AccountGetResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*AccountGetResponse) UnmarshalJSON ¶
func (r *AccountGetResponse) UnmarshalJSON(data []byte) error
type AccountGetResponsePlan ¶
type AccountGetResponsePlan struct {
// The maximum number of characters per billing period allowed by your plan.
CharacterLimit int64 `json:"character_limit" api:"required"`
CommercialUseAllowed bool `json:"commercial_use_allowed" api:"required"`
// The type of plan you are subscribed to.
Type string `json:"type" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
CharacterLimit respjson.Field
CommercialUseAllowed respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (AccountGetResponsePlan) RawJSON ¶
func (r AccountGetResponsePlan) RawJSON() string
Returns the unmodified JSON received from the API
func (*AccountGetResponsePlan) UnmarshalJSON ¶
func (r *AccountGetResponsePlan) UnmarshalJSON(data []byte) error
type AccountGetResponseUsage ¶
type AccountGetResponseUsage struct {
// The number of characters remaining in this billing period.
Characters int64 `json:"characters" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Characters respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (AccountGetResponseUsage) RawJSON ¶
func (r AccountGetResponseUsage) RawJSON() string
Returns the unmodified JSON received from the API
func (*AccountGetResponseUsage) UnmarshalJSON ¶
func (r *AccountGetResponseUsage) UnmarshalJSON(data []byte) error
type AccountService ¶
type AccountService struct {
Options []option.RequestOption
}
AccountService contains methods that help with interacting with the lmnt API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAccountService method.
func NewAccountService ¶
func NewAccountService(opts ...option.RequestOption) (r AccountService)
NewAccountService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*AccountService) Get ¶
func (r *AccountService) Get(ctx context.Context, opts ...option.RequestOption) (res *AccountGetResponse, err error)
Retrieve account
type Client ¶
type Client struct {
Options []option.RequestOption
Speech SpeechService
Voice VoiceService
Account AccountService
}
Client creates a struct with services and top level methods that help with interacting with the lmnt API. You should not instantiate this client directly, and instead use the NewClient method.
func NewClient ¶
func NewClient(opts ...option.RequestOption) (r Client)
NewClient generates a new client with the default options read from the environment. Options passed in as arguments are applied after the defaults, and all options propagate to the services and requests this client makes.
Pass option.WithoutEnvironmentDefaults to skip the environment-based credential autoload entirely.
type ErrorBody ¶
type ErrorBody struct {
// Slug identifying the error category.
Type ErrorType `json:"type" api:"required"`
// Human-readable error message.
Message string `json:"message" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Type respjson.Field
Message respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (*ErrorBody) UnmarshalJSON ¶
type LanguageCode ¶
type LanguageCode = shared.LanguageCode
LanguageCode is an alias to shared.LanguageCode.
type OutputFormat ¶
type OutputFormat = shared.OutputFormat
OutputFormat is an alias to shared.OutputFormat.
type SessionInitFormat ¶
type SessionInitFormat string
The desired output format of the audio. - `mp3`: 96kbps MP3 audio. - `pcm_s16le`: PCM signed 16-bit little-endian audio. - `pcm_f32le`: PCM 32-bit floating-point little-endian audio. - `ulaw`: 8-bit G711 µ-law audio with a WAV header. - `webm`: WebM format with Opus audio codec.
const ( SessionInitFormatMP3 SessionInitFormat = "mp3" SessionInitFormatPCMS16LE SessionInitFormat = "pcm_s16le" SessionInitFormatPCMF32LE SessionInitFormat = "pcm_f32le" SessionInitFormatULaw SessionInitFormat = "ulaw" SessionInitFormatWebM SessionInitFormat = "webm" )
type SessionInitSampleRate ¶
type SessionInitSampleRate int64
The desired output audio sample rate
const ( SessionInitSampleRate24000 SessionInitSampleRate = 24000 SessionInitSampleRate16000 SessionInitSampleRate = 16000 SessionInitSampleRate8000 SessionInitSampleRate = 8000 )
type SessionNewParams ¶
type SessionNewParams struct {
// The voice ID to use for speech generation, obtained from 'List voices' API
Voice string
// The desired output format of the audio.
// - `mp3`: 96kbps MP3 audio.
// - `pcm_s16le`: PCM signed 16-bit little-endian audio.
// - `pcm_f32le`: PCM 32-bit floating-point little-endian audio.
// - `ulaw`: 8-bit G711 µ-law audio with a WAV header.
// - `webm`: WebM format with Opus audio codec.
Format SessionInitFormat
Language LanguageCode
// Controls whether the server will return timestamps for the generated speech
ReturnTimestamps bool
// The desired output audio sample rate
SampleRate SessionInitSampleRate
}
SessionNewParams configures a new speech session.
type SessionService ¶
type SessionService struct {
Options []option.RequestOption
}
SessionService is the WebSocket speech-session resource, reached via the parent service (e.g. client.Speech.Sessions).
func NewSessionService ¶
func NewSessionService(opts ...option.RequestOption) (r SessionService)
NewSessionService generates a new session service that applies the given options to each session it opens.
func (*SessionService) New ¶
func (r *SessionService) New(ctx context.Context, params SessionNewParams, opts ...option.RequestOption) (*SpeechSession, error)
New opens a speech session: it dials the WebSocket (blocking only on the transport-level upgrade), writes the init frame, and returns. It does NOT block on the server's `ready` frame — that arrives via Recv and populates RequestID, so the Send methods may be called immediately.
type SpeechGenerateDetailedParams ¶
type SpeechGenerateDetailedParams struct {
// The text to generate speech from; max 5000 characters per request (including
// spaces).
Text string `json:"text" api:"required"`
// The voice id of the voice to use; voice ids can be retrieved by calls to `List
// voices` or `Voice info`.
Voice string `json:"voice" api:"required"`
// When set to true, the generated speech will also be saved to your [clip
// library](https://app.lmnt.com/clips) in the LMNT playground.
Debug param.Opt[bool] `json:"debug,omitzero"`
// The desired output format of the audio. If you are using a streaming endpoint,
// you'll generate audio faster by selecting a streamable format since chunks are
// encoded and returned as they're generated. For non-streamable formats, all
// speech will be generated before encoding.
//
// Streamable formats:
// - `mp3`: 96kbps MP3 audio.
// - `ulaw`: 8-bit G711 µ-law audio with a WAV header.
// - `webm`: WebM format with Opus audio codec.
// - `pcm_s16le`: PCM signed 16-bit little-endian audio.
// - `pcm_f32le`: PCM 32-bit floating-point little-endian audio.
//
// Non-streamable formats:
// - `aac`: AAC audio codec.
// - `wav`: 16-bit PCM audio in WAV container.
Format OutputFormat `json:"format,omitzero"`
// The desired language. Two letter ISO 639-1 code. Defaults to auto language
// detection, but specifying the language is recommended for faster generation.
Language LanguageCode `json:"language,omitzero"`
// The model to use for speech generation. Learn more about models
// [here](https://docs.lmnt.com/models/overview).
Model Model `json:"model,omitzero"`
// If set as `true`, the response will contain a `timestamps` array describing
// where each input element falls in the generated audio.
ReturnTimestamps param.Opt[bool] `json:"return_timestamps,omitzero"`
// The desired output sample rate in Hz. Defaults to `24000` for all formats except
// `mulaw` which defaults to `8000`.
SampleRate SampleRate `json:"sample_rate,omitzero"`
// Influences how expressive and emotionally varied the speech becomes. Lower
// values (like 0.3) create more neutral, consistent speaking styles. Higher values
// (like 1.0) allow for more dynamic emotional range and speaking styles.
Temperature param.Opt[float64] `json:"temperature,omitzero"`
// Controls the stability of the generated speech. A lower value (like 0.3)
// produces more consistent, reliable speech. A higher value (like 0.9) gives more
// flexibility in how words are spoken, but might occasionally produce unusual
// intonations or speech patterns.
TopP param.Opt[float64] `json:"top_p,omitzero"`
// contains filtered or unexported fields
}
func (SpeechGenerateDetailedParams) MarshalJSON ¶
func (r SpeechGenerateDetailedParams) MarshalJSON() (data []byte, err error)
func (*SpeechGenerateDetailedParams) UnmarshalJSON ¶
func (r *SpeechGenerateDetailedParams) UnmarshalJSON(data []byte) error
type SpeechGenerateDetailedResponse ¶
type SpeechGenerateDetailedResponse struct {
// The base64-encoded audio file; the format is determined by the `format`
// parameter.
Audio string `json:"audio" api:"required"`
// An array describing where each generated input element (words and non-words like
// spaces, punctuation, etc.) falls in the audio.
Timestamps []TimestampObject `json:"timestamps"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Audio respjson.Field
Timestamps respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (SpeechGenerateDetailedResponse) RawJSON ¶
func (r SpeechGenerateDetailedResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*SpeechGenerateDetailedResponse) UnmarshalJSON ¶
func (r *SpeechGenerateDetailedResponse) UnmarshalJSON(data []byte) error
type SpeechGenerateParams ¶
type SpeechGenerateParams struct {
// The text to generate speech from; max 5000 characters per request (including
// spaces).
Text string `json:"text" api:"required"`
// The voice id of the voice to use; voice ids can be retrieved by calls to `List
// voices` or `Voice info`.
Voice string `json:"voice" api:"required"`
// When set to true, the generated speech will also be saved to your [clip
// library](https://app.lmnt.com/clips) in the LMNT playground.
Debug param.Opt[bool] `json:"debug,omitzero"`
// The desired output format of the audio. If you are using a streaming endpoint,
// you'll generate audio faster by selecting a streamable format since chunks are
// encoded and returned as they're generated. For non-streamable formats, all
// speech will be generated before encoding.
//
// Streamable formats:
// - `mp3`: 96kbps MP3 audio.
// - `ulaw`: 8-bit G711 µ-law audio with a WAV header.
// - `webm`: WebM format with Opus audio codec.
// - `pcm_s16le`: PCM signed 16-bit little-endian audio.
// - `pcm_f32le`: PCM 32-bit floating-point little-endian audio.
//
// Non-streamable formats:
// - `aac`: AAC audio codec.
// - `wav`: 16-bit PCM audio in WAV container.
Format OutputFormat `json:"format,omitzero"`
// The desired language. Two letter ISO 639-1 code. Defaults to auto language
// detection, but specifying the language is recommended for faster generation.
Language LanguageCode `json:"language,omitzero"`
// The model to use for speech generation. Learn more about models
// [here](https://docs.lmnt.com/models/overview).
Model Model `json:"model,omitzero"`
// The desired output sample rate in Hz. Defaults to `24000` for all formats except
// `mulaw` which defaults to `8000`.
SampleRate SampleRate `json:"sample_rate,omitzero"`
// Influences how expressive and emotionally varied the speech becomes. Lower
// values (like 0.3) create more neutral, consistent speaking styles. Higher values
// (like 1.0) allow for more dynamic emotional range and speaking styles.
Temperature param.Opt[float64] `json:"temperature,omitzero"`
// Controls the stability of the generated speech. A lower value (like 0.3)
// produces more consistent, reliable speech. A higher value (like 0.9) gives more
// flexibility in how words are spoken, but might occasionally produce unusual
// intonations or speech patterns.
TopP param.Opt[float64] `json:"top_p,omitzero"`
// contains filtered or unexported fields
}
func (SpeechGenerateParams) MarshalJSON ¶
func (r SpeechGenerateParams) MarshalJSON() (data []byte, err error)
func (*SpeechGenerateParams) UnmarshalJSON ¶
func (r *SpeechGenerateParams) UnmarshalJSON(data []byte) error
type SpeechService ¶
type SpeechService struct {
Options []option.RequestOption
Sessions SessionService
}
SpeechService contains methods that help with interacting with the lmnt API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewSpeechService method.
func NewSpeechService ¶
func NewSpeechService(opts ...option.RequestOption) (r SpeechService)
NewSpeechService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*SpeechService) Generate ¶
func (r *SpeechService) Generate(ctx context.Context, body SpeechGenerateParams, opts ...option.RequestOption) (res *http.Response, err error)
Generate speech
func (*SpeechService) GenerateDetailed ¶
func (r *SpeechService) GenerateDetailed(ctx context.Context, body SpeechGenerateDetailedParams, opts ...option.RequestOption) (res *SpeechGenerateDetailedResponse, err error)
Generate speech with timestamps
type SpeechSession ¶
type SpeechSession struct {
// contains filtered or unexported fields
}
SpeechSession is a bidirectional speech-streaming session. The Send methods are safe to call from any goroutine; Recv, Messages, and StreamAudio are single-reader. Close is idempotent. This is the gRPC bidirectional-stream contract.
func (*SpeechSession) Close ¶
func (s *SpeechSession) Close() error
Close shuts the session down. It is idempotent: the first call closes the connection and cancels the reader; later calls return the same result.
func (*SpeechSession) Messages ¶
func (s *SpeechSession) Messages(ctx context.Context) iter.Seq2[SpeechSessionMessage, error]
Messages is the Go 1.23 range-over-func form of Recv. Iteration ends cleanly on a graceful close; a non-EOF error is yielded once and then ends iteration.
func (*SpeechSession) Recv ¶
func (s *SpeechSession) Recv(ctx context.Context) (SpeechSessionMessage, error)
Recv returns the next message from the server. Single-reader: do not call it concurrently with itself, Messages, or StreamAudio. Returns io.EOF on a graceful close (by Close or by the server).
func (*SpeechSession) RequestID ¶
func (s *SpeechSession) RequestID() string
RequestID returns the per-session request id once the server's `ready` frame has been received and consumed via Recv. Returns "" before then. Safe for concurrent use.
func (*SpeechSession) SendFinish ¶
func (s *SpeechSession) SendFinish(ctx context.Context) error
Inform the server you're done appending text to this session and want it to close when the server has finished dispatching speech.
func (*SpeechSession) SendFlush ¶
func (s *SpeechSession) SendFlush(ctx context.Context) (nonce int64, err error)
Force the server to generate speech for all buffered text in the stream.
The server replies with a `flush_complete` carrying a matching `nonce` once it has finished streaming the flushed audio.
<Warning> Be careful when using `flush`. Our models are designed to factor in context when generating speech. When flushing the buffer at arbitrary points, your speech may sound less natural. </Warning>
The returned nonce is echoed back by the matching acknowledgement.
func (*SpeechSession) SendReset ¶
func (s *SpeechSession) SendReset(ctx context.Context) (nonce int64, err error)
Drop the server's buffered text without generating speech for it.
The server replies with a `reset_complete` carrying the matching `nonce` once the buffer has been cleared.
You do not need to wait for `reset_complete` to begin sending more text.
The returned nonce is echoed back by the matching acknowledgement.
func (*SpeechSession) SendText ¶
func (s *SpeechSession) SendText(ctx context.Context, text string) error
Send text to the server to append into the text stream.
The text you send can be split at any point. For example, sending `This is a test of the emergency broadcast system` is semantically equivalent to sending `This is a test of the eme` and `rgency broadcast system` separately.
func (*SpeechSession) StreamAudio ¶
StreamAudio drains audio frames to w until the session closes cleanly (returning nil) or the server sends an error frame (returned as a wrapped error). Non-audio, non-error frames are skipped.
type SpeechSessionAudio ¶
type SpeechSessionAudio struct {
// Data is a copy of the frame bytes, safe to retain.
Data []byte
}
Binary audio data returned from the server.
type SpeechSessionError ¶
type SpeechSessionError struct {
Detail ErrorBody `json:"error" api:"required"`
// Per-session request ID. If you're reporting an issue, include this if possible
// to make debugging easier.
RequestID string `json:"request_id" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Detail respjson.Field
RequestID respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Error envelope returned by the server. Connection closes immediately afterward.
func (*SpeechSessionError) Error ¶
func (e *SpeechSessionError) Error() string
Error implements the error interface so SpeechSessionError composes with errors.Is / errors.As and can be returned directly by StreamAudio.
func (SpeechSessionError) RawJSON ¶
func (r SpeechSessionError) RawJSON() string
Returns the unmodified JSON received from the API
func (*SpeechSessionError) Type ¶
func (e *SpeechSessionError) Type() ErrorType
Type returns the API error category, for parity with apierror.Error.Type().
func (*SpeechSessionError) UnmarshalJSON ¶
func (r *SpeechSessionError) UnmarshalJSON(data []byte) error
type SpeechSessionFlushComplete ¶
type SpeechSessionFlushComplete struct {
// The nonce that was carried by the original `flush`.
Nonce int64 `json:"nonce" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Nonce respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Acknowledgement that a flush command has been completed.
The `nonce` matches the one carried by the original flush, allowing you to determine when it has completed.
func (SpeechSessionFlushComplete) RawJSON ¶
func (r SpeechSessionFlushComplete) RawJSON() string
Returns the unmodified JSON received from the API
func (*SpeechSessionFlushComplete) UnmarshalJSON ¶
func (r *SpeechSessionFlushComplete) UnmarshalJSON(data []byte) error
type SpeechSessionMessage ¶
type SpeechSessionMessage interface {
// contains filtered or unexported methods
}
SpeechSessionMessage is the sealed receive-side union. Type-switch on it after Recv.
type SpeechSessionReady ¶
type SpeechSessionReady struct {
// Per-session request ID. If you're reporting an issue, include this if possible
// to make debugging easier.
RequestID string `json:"request_id" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
RequestID respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
First message sent by the server, confirming the session is established.
func (SpeechSessionReady) RawJSON ¶
func (r SpeechSessionReady) RawJSON() string
Returns the unmodified JSON received from the API
func (*SpeechSessionReady) UnmarshalJSON ¶
func (r *SpeechSessionReady) UnmarshalJSON(data []byte) error
type SpeechSessionResetComplete ¶
type SpeechSessionResetComplete struct {
// The nonce that was carried by the original `reset`.
Nonce int64 `json:"nonce" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Nonce respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Acknowledgement that a reset command has been completed.
The `nonce` matches the one carried by the original reset, allowing you to discard any remaining in-flight speech before the reset.
func (SpeechSessionResetComplete) RawJSON ¶
func (r SpeechSessionResetComplete) RawJSON() string
Returns the unmodified JSON received from the API
func (*SpeechSessionResetComplete) UnmarshalJSON ¶
func (r *SpeechSessionResetComplete) UnmarshalJSON(data []byte) error
type SpeechSessionTimestamps ¶
type SpeechSessionTimestamps struct {
// Array of timestamp objects, one per generated text token.
//
// <Warning>
// The timestamps array resets its start time for each chunk of audio.
// </Warning>
Timestamps []Timestamp `json:"timestamps"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Timestamps respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Timestamps for the audio chunk that was just streamed, if requested in `init`.
func (SpeechSessionTimestamps) RawJSON ¶
func (r SpeechSessionTimestamps) RawJSON() string
Returns the unmodified JSON received from the API
func (*SpeechSessionTimestamps) UnmarshalJSON ¶
func (r *SpeechSessionTimestamps) UnmarshalJSON(data []byte) error
type Timestamp ¶
type Timestamp struct {
// The text segment
Text string `json:"text" api:"required"`
// The time at which the text starts, in seconds
Start float64 `json:"start" api:"required"`
// The spoken duration of the text segment, in seconds
Duration float64 `json:"duration" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Text respjson.Field
Start respjson.Field
Duration respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (*Timestamp) UnmarshalJSON ¶
type TimestampObject ¶
type TimestampObject struct {
// The spoken duration of the generated input element, in seconds.
Duration float64 `json:"duration" api:"required"`
// The start time of the generated input element, in seconds.
Start float64 `json:"start" api:"required"`
// The generated input element; beginning and ending with a short silence.
Text string `json:"text" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Duration respjson.Field
Start respjson.Field
Text respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (TimestampObject) RawJSON ¶
func (r TimestampObject) RawJSON() string
Returns the unmodified JSON received from the API
func (*TimestampObject) UnmarshalJSON ¶
func (r *TimestampObject) UnmarshalJSON(data []byte) error
type Voice ¶
type Voice struct {
// The unique identifier of this voice.
ID string `json:"id" api:"required"`
// The display name of this voice.
Name string `json:"name" api:"required"`
// The owner of this voice.
Owner VoiceOwner `json:"owner" api:"required"`
// The state of this voice in the training pipeline (e.g., `ready`, `training`).
State string `json:"state" api:"required"`
// A text description of this voice.
Description string `json:"description" api:"nullable"`
// A tag describing the gender of this voice, e.g. `male`, `female`, `nonbinary`.
Gender string `json:"gender"`
// A URL that returns a preview speech sample of this voice. The file can be played
// directly in a browser or audio player.
PreviewURL string `json:"preview_url"`
// Whether this voice has been starred by you or not.
Starred bool `json:"starred"`
// Tags attached to this voice.
Tags []string `json:"tags"`
// The method by which this voice was created. Always `instant`.
Type VoiceType `json:"type"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Name respjson.Field
Owner respjson.Field
State respjson.Field
Description respjson.Field
Gender respjson.Field
PreviewURL respjson.Field
Starred respjson.Field
Tags respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Voice details
func (*Voice) UnmarshalJSON ¶
type VoiceDeleteResponse ¶
type VoiceDeleteResponse struct {
Success bool `json:"success" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Success respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (VoiceDeleteResponse) RawJSON ¶
func (r VoiceDeleteResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*VoiceDeleteResponse) UnmarshalJSON ¶
func (r *VoiceDeleteResponse) UnmarshalJSON(data []byte) error
type VoiceListParams ¶
type VoiceListParams struct {
// Which owner's voices to return. Choose from `system`, `me`, or `all`.
Owner param.Opt[string] `query:"owner,omitzero" json:"-"`
// If true, only returns voices that you have starred.
Starred param.Opt[string] `query:"starred,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (VoiceListParams) URLQuery ¶
func (r VoiceListParams) URLQuery() (v url.Values, err error)
URLQuery serializes VoiceListParams's query parameters as `url.Values`.
type VoiceNewParams ¶
type VoiceNewParams struct {
// The input audio file to train the voice with, as a binary `wav`, `mp3`, `mp4`,
// `m4a`, or `webm` attachment.
// - Max file size: 250 MB.
File io.Reader `json:"file" api:"required"`
// The display name for this voice
Name string `json:"name" api:"required"`
// A text description of this voice.
Description param.Opt[string] `json:"description,omitzero"`
// A tag describing the gender of this voice. Has no effect on voice creation.
Gender param.Opt[string] `json:"gender,omitzero"`
// A list of tags to attach to this voice.
Tags []string `json:"tags,omitzero"`
// contains filtered or unexported fields
}
func (VoiceNewParams) MarshalMultipart ¶
func (r VoiceNewParams) MarshalMultipart() (data []byte, contentType string, err error)
type VoiceOwner ¶
type VoiceOwner string
The owner of this voice.
const ( VoiceOwnerSystem VoiceOwner = "system" VoiceOwnerMe VoiceOwner = "me" VoiceOwnerOther VoiceOwner = "other" )
type VoiceService ¶
type VoiceService struct {
Options []option.RequestOption
}
VoiceService contains methods that help with interacting with the lmnt API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewVoiceService method.
func NewVoiceService ¶
func NewVoiceService(opts ...option.RequestOption) (r VoiceService)
NewVoiceService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*VoiceService) Delete ¶
func (r *VoiceService) Delete(ctx context.Context, id string, opts ...option.RequestOption) (res *VoiceDeleteResponse, err error)
Delete voice
func (*VoiceService) Get ¶
func (r *VoiceService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *Voice, err error)
Retrieve voice
func (*VoiceService) List ¶
func (r *VoiceService) List(ctx context.Context, query VoiceListParams, opts ...option.RequestOption) (res *[]Voice, err error)
List voices
func (*VoiceService) New ¶
func (r *VoiceService) New(ctx context.Context, body VoiceNewParams, opts ...option.RequestOption) (res *Voice, err error)
Create voice
func (*VoiceService) Update ¶
func (r *VoiceService) Update(ctx context.Context, id string, body VoiceUpdateParams, opts ...option.RequestOption) (res *VoiceUpdateResponse, err error)
Update voice
type VoiceType ¶
type VoiceType string
The method by which this voice was created. Always `instant`.
const (
VoiceTypeInstant VoiceType = "instant"
)
type VoiceUpdateParams ¶
type VoiceUpdateParams struct {
// A description of this voice.
Description param.Opt[string] `json:"description,omitzero"`
// A tag describing the gender of this voice, e.g. `male`, `female`, `nonbinary`.
Gender param.Opt[string] `json:"gender,omitzero"`
// The display name for this voice.
Name param.Opt[string] `json:"name,omitzero"`
// If `true`, adds this voice to your starred list.
Starred param.Opt[bool] `json:"starred,omitzero"`
// Replaces the tags attached to this voice with the given list.
Tags []string `json:"tags,omitzero"`
// contains filtered or unexported fields
}
func (VoiceUpdateParams) MarshalJSON ¶
func (r VoiceUpdateParams) MarshalJSON() (data []byte, err error)
func (*VoiceUpdateParams) UnmarshalJSON ¶
func (r *VoiceUpdateParams) UnmarshalJSON(data []byte) error
type VoiceUpdateResponse ¶
type VoiceUpdateResponse struct {
// Voice details
Voice Voice `json:"voice" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Voice respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (VoiceUpdateResponse) RawJSON ¶
func (r VoiceUpdateResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*VoiceUpdateResponse) UnmarshalJSON ¶
func (r *VoiceUpdateResponse) UnmarshalJSON(data []byte) error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
|
Package json implements encoding and decoding of JSON as defined in RFC 7159. |
|
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
|
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package. |
|
packages
|
|
|
wsstream
Package wsstream is a minimal WebSocket transport for the LMNT SDK's streaming session resource.
|
Package wsstream is a minimal WebSocket transport for the LMNT SDK's streaming session resource. |