google

package
v0.67.21 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvAPIKey                 = envGoogleSTTAPIKey
	EnvCloudAPIKey            = envGoogleCloudSTTAPIKey
	EnvLegacyAPIKey           = envGoogleLegacySTTAPIKey
	EnvCredentialsJSON        = envGoogleSTTCredentialsJSON
	EnvApplicationCredentials = envGoogleApplicationCreds
)

Credential env names a host can present to a user when streaming transcription is unavailable for lack of credentials.

Variables

This section is empty.

Functions

func StreamingCredentialsPresent added in v0.64.3

func StreamingCredentialsPresent() bool

StreamingCredentialsPresent reports whether service-account or ADC credentials are configured for streaming recognition under the default env names, consulting the process environment and the process-wide secret resolver. Batch transcription only needs an API key and is unaffected. Use (*Provider).StreamingCredentialsPresent to honour a per-instance resolver and custom env names.

Types

type Provider

type Provider struct {
	APIKey                    string
	Model                     string // "latest_long", "latest_short", or another Google STT v1 model tag
	STTCredentialsJSONEnv     string
	ApplicationCredentialsEnv string
	BaseURL                   string // Override for testing; defaults to googleSTTBaseURL
	Validation                netsec.ValidationOptions
	// SecretResolver resolves the streaming credential env names
	// (STTCredentialsJSONEnv, ApplicationCredentialsEnv, GOOGLE_CLOUD_PROJECT)
	// when they are not present in the process environment. Nil falls back to
	// the process environment.
	SecretResolver stt.SecretResolver
	// contains filtered or unexported fields
}

Provider implements stt.STTProvider for Google Cloud Speech-to-Text v1 REST API.

BaseURL is user-configurable (for testing or regional endpoints). It is validated against Validation on every request. Default Validation is strict (public https only).

func New

func New(apiKey, model string) *Provider

New creates a provider for Google Cloud Speech-to-Text. Model defaults to "latest_long" if empty.

func (*Provider) Capabilities added in v0.64.3

func (*Provider) Capabilities() []speechkit.Capability

Capabilities reports what this provider does beyond plain transcription.

func (*Provider) Health added in v0.64.3

func (p *Provider) Health(ctx context.Context) error

Health checks if the Google Speech API is reachable.

func (*Provider) Name added in v0.64.3

func (p *Provider) Name() string

Name returns the provider identifier.

func (*Provider) SetStreamingCredentialEnvs added in v0.64.3

func (p *Provider) SetStreamingCredentialEnvs(credentialsJSONEnv, applicationCredentialsEnv string)

func (*Provider) StartSpeakerStream added in v0.64.3

func (p *Provider) StartSpeakerStream(ctx context.Context, opts speaker.Options, format speaker.AudioFormat) (speaker.SpeakerStream, error)

StartSpeakerStream opens a Google Cloud Speech-to-Text v2 StreamingRecognize session.

IMPORTANT: Google STT v2 does NOT support speaker diarization in streaming mode — diarization is available only in BatchRecognize/Recognize (see the Chirp-3 docs). This adapter therefore provides realtime TRANSCRIPTION only: frames carry Text without speaker labels (no Segment/Speakers). Streaming speaker diarization in the Voice Agent comes from Deepgram/AssemblyAI.

func (*Provider) StreamingCredentialsPresent added in v0.67.14

func (p *Provider) StreamingCredentialsPresent() bool

StreamingCredentialsPresent reports whether this provider can open a streaming session: it checks the provider's configured env names through its SecretResolver.

func (*Provider) Transcribe added in v0.64.3

func (p *Provider) Transcribe(ctx context.Context, audio []byte, opts stt.TranscribeOpts) (*stt.Result, error)

Transcribe sends audio to Google Cloud Speech-to-Text v1 REST API.

Jump to

Keyboard shortcuts

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