in-process

command
v0.68.21 Latest Latest
Warning

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

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

README

assist/in-process

Fully in-process Assist: text (or speech) in, one useful result out, no SpeechKit server. It wires a real LLM Generator (Gemini via the genai SDK) into pkg/speechkit/assist.Service, and — when an OpenAI key is present — the public pkg/speechkit/tts router for spoken output.

Requirements

  • GOOGLE_AI_API_KEY (a Google AI Studio key) — required.
  • OPENAI_API_KEY — optional; enables spoken output through the public TTS router.
  • -model flag selects the Gemini generateContent model (default gemini-2.5-flash).

Run

GOOGLE_AI_API_KEY=... go run ./examples/assist/in-process
# optional spoken output: also set OPENAI_API_KEY

Expected output

An interactive stdin loop. Type a request and press Enter; the assistant answers with one or two short sentences per line (assist: ...). With TTS enabled, each answer also reports the synthesized audio size ((+N bytes of <format> audio)). An empty line quits.

Documentation

Overview

Example: fully in-process Assist — text (or speech) in, one useful result out, no SpeechKit server.

It wires a real LLM Generator (Gemini via the genai SDK) into pkg/speechkit/assist.Service, and — when an OpenAI key is present — the public pkg/speechkit/tts router for spoken output. This demonstrates that Assist and TTS are embeddable in-process: the host owns the LLM call and SpeechKit owns the pipeline (codeword/utility/LLM -> one-shot result -> optional TTS).

Audio-in: this demo takes text on stdin to stay portable. To go from speech, transcribe a WAV with a public STT provider first, e.g.

p := openaicompat.NewOpenAISTTProvider(os.Getenv("OPENAI_API_KEY")) // pkg/speechkit/stt
res, _ := p.Transcribe(ctx, wav, stt.TranscribeOpts{})
req := speechkit.AssistRequest{Text: res.Text}

Run:

GOOGLE_AI_API_KEY=... go run ./examples/assist/in-process
# optional spoken output (public TTS router): also set OPENAI_API_KEY

Jump to

Keyboard shortcuts

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