### Install Dependencies and Run Development Server Source: https://github.com/tover0314-w/opentypeless/blob/main/README_id.md Use these commands to install project dependencies and start the development server for OpenTypeless. Ensure Node.js 20+ and Rust stable toolchain are installed. ```bash npm install npm run tauri dev ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/tover0314-w/opentypeless/blob/main/README_es.md Install the necessary project dependencies using npm. ```bash npm install ``` -------------------------------- ### Install Dependencies and Run Tauri Application Source: https://github.com/tover0314-w/opentypeless/blob/main/README.md Use these npm commands to install project dependencies, run the application in development mode, or build it for production. Ensure Node.js 20+ and Rust are installed. ```bash npm install npm run tauri dev npm run tauri build ``` -------------------------------- ### Start Recording and Listen for Events Source: https://context7.com/tover0314-w/opentypeless/llms.txt Initiates the recording process and sets up listeners for pipeline state changes, audio volume, and real-time transcriptions. Ensure you have the necessary imports from '@tauri-apps/api'. ```typescript import { invoke } from '@tauri-apps/api/core' // Start recording - triggers audio capture and STT streaming await invoke('start_recording') // Listen for pipeline state changes import { listen } from '@tauri-apps/api/event' await listen<'idle' | 'recording' | 'transcribing' | 'polishing' | 'outputting'>('pipeline:state', (event) => { console.log('Pipeline state:', event.payload) }) // Listen for real-time audio volume (0.0 - 1.0) await listen('audio:volume', (event) => { console.log('Volume:', event.payload) }) // Listen for partial transcripts (streaming STT) await listen('stt:partial', (event) => { console.log('Partial:', event.payload) }) // Listen for final transcripts await listen('stt:final', (event) => { console.log('Final:', event.payload) }) ``` -------------------------------- ### Configure and Start Audio Capture Source: https://context7.com/tover0314-w/opentypeless/llms.txt Set up audio capture with a specific sample rate, channels, and chunk duration. This returns a handle for control and a receiver for audio data. ```rust use crate::audio::{AudioCaptureHandle, AudioConfig}; let config = AudioConfig { sample_rate: 16000, // Target sample rate channels: 1, // Mono chunk_duration_ms: 20, }; let (handle, mut audio_rx) = AudioCaptureHandle::start(config)?; ``` -------------------------------- ### Get and Update Application Configuration Source: https://context7.com/tover0314-w/opentypeless/llms.txt Loads the current application configuration and provides an example of how to update it. Configuration is managed using tauri-plugin-store. Ensure the `AppConfig` interface matches the expected structure. ```typescript import { invoke } from '@tauri-apps/api/core' interface AppConfig { stt_provider: 'deepgram' | 'assemblyai' | 'glm-asr' | 'openai-whisper' | 'groq-whisper' | 'siliconflow' | 'cloud' stt_api_key: string stt_language: string // 'multi' for auto-detect, or BCP-47 code like 'en', 'zh', 'ja' llm_provider: string llm_api_key: string llm_model: string llm_base_url: string polish_enabled: boolean translate_enabled: boolean target_lang: string hotkey: string // e.g., 'Ctrl+/' or 'Alt+/' hotkey_mode: 'hold' | 'toggle' output_mode: 'keyboard' | 'clipboard' selected_text_enabled: boolean theme: 'light' | 'dark' | 'system' auto_start: boolean close_to_tray: boolean start_minimized: boolean max_recording_seconds: number ui_language: string capsule_auto_hide: boolean } // Load current configuration const config: AppConfig = await invoke('get_config') console.log('STT Provider:', config.stt_provider) console.log('LLM Model:', config.llm_model) // Update configuration const newConfig: AppConfig = { ...config, stt_provider: 'groq-whisper', llm_provider: 'openrouter', llm_model: 'google/gemini-2.5-flash', llm_base_url: 'https://openrouter.ai/api/v1', polish_enabled: true, hotkey_mode: 'hold', output_mode: 'keyboard' } await invoke('update_config', { config: newConfig }) ``` -------------------------------- ### Commit Message Examples Source: https://github.com/tover0314-w/opentypeless/blob/main/CONTRIBUTING.md Examples of valid commit messages using the Conventional Commits format. ```text feat: add Groq Whisper STT provider fix: resolve audio recording crash on macOS docs: update README installation steps ``` -------------------------------- ### Run Tauri in Development Mode Source: https://context7.com/tover0314-w/opentypeless/llms.txt Start the Tauri application in development mode, which includes hot reloading for faster iteration. ```bash # Run in development mode (hot reload) npm run tauri dev ``` -------------------------------- ### Receive and Process Audio Chunks Source: https://context7.com/tover0314-w/opentypeless/llms.txt Continuously receive audio data chunks in 16-bit PCM format from the audio receiver. Process each chunk as needed, for example, by sending it to a provider. ```rust // Receive audio chunks in 16-bit PCM format while let Some(chunk) = audio_rx.recv().await { // chunk is Vec containing 16-bit little-endian PCM samples provider.send_audio(&chunk).await?; } ``` -------------------------------- ### Development Commands Source: https://github.com/tover0314-w/opentypeless/blob/main/CONTRIBUTING.md Commands for setting up and running the development environment. ```bash npm install ``` ```bash npm run tauri dev ``` ```bash git checkout -b feat/my-feature ``` -------------------------------- ### Build with Custom Backend Source: https://github.com/tover0314-w/opentypeless/blob/main/README.md Set environment variables to point cloud features to a custom backend before building the application. ```bash VITE_API_BASE_URL=https://my-server.example.com API_BASE_URL=https://my-server.example.com npm run tauri build ``` -------------------------------- ### Build Tauri Application for Production Source: https://context7.com/tover0314-w/opentypeless/llms.txt Compile the Tauri application into a production-ready build. ```bash # Build for production npm run tauri build ``` -------------------------------- ### Create and Use OpenAI-Compatible LLM Provider Source: https://context7.com/tover0314-w/opentypeless/llms.txt Instantiate an LLM provider and use it for text polishing with streaming support. Ensure the provider name and HTTP client are correctly configured. ```rust // Create OpenAI-compatible provider let provider = llm::create_provider("openrouter", Some(http_client)); let response = provider.polish(&config, &request, Some(&|chunk| { println!("Streaming: {}", chunk); })).await?; println!("Final: {}", response.polished_text); ``` -------------------------------- ### System Settings Source: https://context7.com/tover0314-w/opentypeless/llms.txt Manage application-level settings. ```APIDOC ## POST set_auto_start - **enabled** (boolean) - Required - Enable or disable auto-start on login ## POST set_session_token - **token** (string) - Required - Cloud provider session token ``` -------------------------------- ### Build Tauri with Custom Backend Configuration Source: https://context7.com/tover0314-w/opentypeless/llms.txt Build the Tauri application for production while specifying custom backend API URLs using environment variables. ```bash # Build with custom backend VITE_API_BASE_URL=https://my-server.example.com \ API_BASE_URL=https://my-server.example.com \ npm run tauri build ``` -------------------------------- ### Project Directory Structure Source: https://github.com/tover0314-w/opentypeless/blob/main/README.md Overview of the source code organization for the React frontend and Rust backend. ```text src/ # React frontend (TypeScript) ├── components/ # UI components (Settings, History, Capsule, etc.) ├── hooks/ # React hooks (recording, theme, Tauri events) ├── lib/ # Utilities (API client, router, constants) └── stores/ # Zustand state management src-tauri/src/ # Rust backend ├── audio/ # Audio capture via cpal ├── stt/ # STT providers (Deepgram, AssemblyAI, Whisper-compat, Cloud) ├── llm/ # LLM providers (OpenAI-compat, Cloud) ├── output/ # Text output (keyboard simulation, clipboard paste) ├── storage/ # Config (tauri-plugin-store) + history/dictionary (SQLite) ├── app_detector/ # Detect active application for context ├── pipeline.rs # Recording → STT → LLM → Output orchestration └── lib.rs # Tauri app setup, commands, hotkey handling ``` -------------------------------- ### Run Project Tests Source: https://context7.com/tover0314-w/opentypeless/llms.txt Execute all tests for the project, including both npm and cargo tests. ```bash # Run tests npm test cargo test -p opentypeless ``` -------------------------------- ### Configure Auto-Start Source: https://context7.com/tover0314-w/opentypeless/llms.txt Enables or disables the application's auto-start behavior on login. ```typescript import { invoke } from '@tauri-apps/api/core' // Enable auto-start await invoke('set_auto_start', { enabled: true }) // Disable auto-start await invoke('set_auto_start', { enabled: false }) ``` -------------------------------- ### Pre-Submit Checklist Source: https://github.com/tover0314-w/opentypeless/blob/main/CONTRIBUTING.md Commands to verify code quality for both frontend and Rust components before submitting a pull request. ```bash # Frontend npx tsc --noEmit npx eslint src/ npx prettier --check src/ npx vitest run # Rust cargo fmt --check --manifest-path src-tauri/Cargo.toml cargo clippy --manifest-path src-tauri/Cargo.toml -- -D warnings cargo test --manifest-path src-tauri/Cargo.toml ``` -------------------------------- ### Build with Custom Backend URL Source: https://github.com/tover0314-w/opentypeless/blob/main/README_tr.md Set environment variables for custom backend API URLs before building the application to redirect optional cloud features to your own backend. ```bash # Example: build with custom backend VITE_API_BASE_URL=https://my-server.example.com API_BASE_URL=https://my-server.example.com npm run tauri build ``` -------------------------------- ### OpenTypeless Architecture Overview Source: https://github.com/tover0314-w/opentypeless/blob/main/README_tr.md This diagram illustrates the data flow pipeline from microphone input to final output, and the project structure for both the React frontend and Rust backend. ```text Mikrofon → Ses Yakalama → STT Sağlayıcı → Ham Transkript → LLM Cilalama → Klavye/Pano Çıktısı ``` ```text src/ # React ön uç (TypeScript) ├── components/ # UI bileşenleri (Ayarlar, Geçmiş, Kapsül, vb.) ├── hooks/ # React hook'ları (kayıt, tema, Tauri olayları) ├── lib/ # Yardımcı araçlar (API istemcisi, yönlendirici, sabitler) └── stores/ # Zustand durum yönetimi src-tauri/src/ # Rust arka uç ├── audio/ # cpal ile ses yakalama ├── stt/ # STT sağlayıcılar (Deepgram, AssemblyAI, Whisper uyumlu, Cloud) ├── llm/ # LLM sağlayıcılar (OpenAI uyumlu, Cloud) ├── output/ # Metin çıktısı (klavye simülasyonu, pano yapıştırma) ├── storage/ # Yapılandırma (tauri-plugin-store) + geçmiş/sözlük (SQLite) ├── app_detector/ # Bağlam için aktif uygulama algılama ├── pipeline.rs # Kayıt → STT → LLM → Çıktı orkestrasyonu └── lib.rs # Tauri uygulama kurulumu, komutlar, kısayol tuşu işleme ``` -------------------------------- ### Access Application State with useAppStore Source: https://context7.com/tover0314-w/opentypeless/llms.txt Provides access to the central Zustand store for managing pipeline status, audio volume, and configuration. ```typescript import { useAppStore } from './stores/appStore' function RecordingStatus() { const { pipelineState, audioVolume, partialTranscript, finalTranscript, polishedText, config, updateConfig } = useAppStore() // Pipeline states: 'idle' | 'recording' | 'transcribing' | 'polishing' | 'outputting' const isRecording = pipelineState === 'recording' const isProcessing = pipelineState === 'transcribing' || pipelineState === 'polishing' // Update config partially const enablePolish = () => { updateConfig({ polish_enabled: true }) } return (

State: {pipelineState}

Volume: {Math.round(audioVolume * 100)}%

Partial: {partialTranscript}

Final: {finalTranscript}

Polished: {polishedText}

) } ``` -------------------------------- ### Hotkey Management Source: https://context7.com/tover0314-w/opentypeless/llms.txt Manage global recording hotkeys. ```APIDOC ## POST update_hotkey - **hotkey** (string) - Required - The hotkey combination string ## POST pause_hotkey - Pauses global hotkey detection. ## POST resume_hotkey - Resumes global hotkey detection. ``` -------------------------------- ### Create and Use TextOutput Implementation Source: https://context7.com/tover0314-w/opentypeless/llms.txt Instantiate a text output handler based on the desired output mode and use it to type text. ```rust // Create output by mode let output = output::create_output(OutputMode::Keyboard); output.type_text("Hello, world!").await?; ``` -------------------------------- ### Stop Recording and Listen for Post-Processing Events Source: https://context7.com/tover0314-w/opentypeless/llms.txt Stops the recording and initiates the full pipeline, including STT finalization, LLM polishing, and output. It also sets up listeners for LLM streaming chunks, pipeline errors, and timing metrics. This command can capture selected text from the foreground app for LLM context if enabled. ```typescript import { invoke } from '@tauri-apps/api/core' import { listen } from '@tauri-apps/api/event' // Stop recording - triggers STT finalization, LLM polish, and output await invoke('stop_recording') // Listen for LLM streaming chunks during polish phase await listen('llm:chunk', (event) => { console.log('LLM chunk:', event.payload) }) // Listen for pipeline errors await listen('pipeline:error', (event) => { console.error('Error:', event.payload) }) // Listen for timing metrics after completion await listen<{ stt_ms: number llm_ms: number total_ms: number recording_ms: number | null }>('pipeline:timing', (event) => { console.log('Timing:', event.payload) }) ``` -------------------------------- ### Manage Audio Capture Handle Source: https://context7.com/tover0314-w/opentypeless/llms.txt Obtain the current audio volume and stop the audio capture process using the handle. ```rust // Get current audio volume (0.0 - 1.0) let volume = handle.get_volume(); // Stop capture handle.stop(); ``` -------------------------------- ### Provider Connectivity and Benchmarking Source: https://context7.com/tover0314-w/opentypeless/llms.txt Endpoints to test connectivity and measure latency for STT and LLM providers. ```APIDOC ## POST test_stt_connection / test_llm_connection ### Description Tests the connectivity to the specified STT or LLM provider. ### Request Body - **apiKey** (string) - Required - API key for the provider - **provider** (string) - Required - Provider identifier - **baseUrl** (string) - Optional - Base URL for LLM provider - **model** (string) - Optional - Model name for LLM provider ### Response - **boolean** - Returns true if connection succeeds. ## POST bench_stt_connection / bench_llm_connection ### Description Measures round-trip latency to the specified provider. ### Response - **number** - Latency in milliseconds. ``` -------------------------------- ### Manage Recording with useRecording Hook Source: https://context7.com/tover0314-w/opentypeless/llms.txt Wraps recording commands and state management into a convenient hook for UI components. ```typescript import { useRecording } from './hooks/useRecording' function RecordButton() { const { startRecording, stopRecording, isRecording, isProcessing, isIdle, pipelineState } = useRecording() const handleClick = async () => { if (isIdle) { await startRecording() } else if (isRecording) { await stopRecording() } } return ( ) } ``` -------------------------------- ### Set Custom Cloud API Endpoint Source: https://context7.com/tover0314-w/opentypeless/llms.txt Configure custom API endpoints for the cloud backend using environment variables. This is optional and useful for self-hosting. ```bash # Custom cloud API endpoint (optional, for self-hosting) export VITE_API_BASE_URL=https://my-server.example.com export API_BASE_URL=https://my-server.example.com ``` -------------------------------- ### Data Flow Pipeline Source: https://github.com/tover0314-w/opentypeless/blob/main/README.md Visual representation of the audio processing pipeline from capture to output. ```text Microphone → Audio Capture → STT Provider → Raw Transcript → LLM Polish → Keyboard/Clipboard Output ``` -------------------------------- ### Lint and Format Code Source: https://context7.com/tover0314-w/opentypeless/llms.txt Apply code linting and formatting rules using npm and cargo commands. ```bash # Lint and format npm run lint npm run format cargo fmt cargo clippy ``` -------------------------------- ### Initiate Stripe Checkout Session Source: https://context7.com/tover0314-w/opentypeless/llms.txt Redirects the user to a Stripe checkout page for Pro subscription upgrades. ```typescript import { createCheckout } from './lib/api' const { url } = await createCheckout('desktop') // Redirect to Stripe checkout window.location.href = url ``` -------------------------------- ### Configuration API Source: https://context7.com/tover0314-w/opentypeless/llms.txt API endpoints for retrieving and updating the application's configuration. ```APIDOC ## GET /get_config ### Description Loads and returns the current application configuration. ### Method GET ### Endpoint /get_config ### Parameters None ### Request Example ```typescript import { invoke } from '@tauri-apps/api/core' interface AppConfig { stt_provider: 'deepgram' | 'assemblyai' | 'glm-asr' | 'openai-whisper' | 'groq-whisper' | 'siliconflow' | 'cloud' stt_api_key: string stt_language: string llm_provider: string llm_api_key: string llm_model: string llm_base_url: string polish_enabled: boolean translate_enabled: boolean target_lang: string hotkey: string hotkey_mode: 'hold' | 'toggle' output_mode: 'keyboard' | 'clipboard' selected_text_enabled: boolean theme: 'light' | 'dark' | 'system' auto_start: boolean close_to_tray: boolean start_minimized: boolean max_recording_seconds: number ui_language: string capsule_auto_hide: boolean } const config: AppConfig = await invoke('get_config') console.log('STT Provider:', config.stt_provider) ``` ### Response #### Success Response (200) Returns the application configuration object. - **config** (AppConfig) - The current application configuration. ### Response Example ```json { "stt_provider": "deepgram", "stt_api_key": "YOUR_DEEPGRAM_API_KEY", "stt_language": "en", "llm_provider": "openai", "llm_api_key": "YOUR_OPENAI_API_KEY", "llm_model": "gpt-4o", "llm_base_url": "", "polish_enabled": true, "translate_enabled": false, "target_lang": "en", "hotkey": "Ctrl+/", "hotkey_mode": "hold", "output_mode": "keyboard", "selected_text_enabled": true, "theme": "system", "auto_start": false, "close_to_tray": true, "start_minimized": false, "max_recording_seconds": 0, "ui_language": "en", "capsule_auto_hide": true } ``` ## POST /update_config ### Description Saves the provided application configuration. Configuration is persisted via tauri-plugin-store. ### Method POST ### Endpoint /update_config ### Parameters #### Request Body - **config** (AppConfig) - Required - The new application configuration object to save. ### Request Example ```typescript import { invoke } from '@tauri-apps/api/core' interface AppConfig { /* ... same as get_config ... */ } const newConfig: AppConfig = { // ... existing config properties ... stt_provider: 'groq-whisper', llm_provider: 'openrouter', llm_model: 'google/gemini-2.5-flash', llm_base_url: 'https://openrouter.ai/api/v1', polish_enabled: true, hotkey_mode: 'hold', output_mode: 'keyboard' } await invoke('update_config', { config: newConfig }) ``` ### Response #### Success Response (200) Indicates that the configuration was successfully updated. #### Response Example null ``` -------------------------------- ### Implement SttProvider Trait in Rust Source: https://context7.com/tover0314-w/opentypeless/llms.txt Defines the interface for pluggable speech-to-text backends and demonstrates provider initialization. ```rust use async_trait::async_trait; use anyhow::Result; pub struct SttConfig { pub api_key: String, pub language: Option, // None for auto-detect pub smart_format: bool, pub sample_rate: u32, } pub enum TranscriptEvent { Partial { text: String }, Final { text: String, confidence: f32 }, SpeechStarted, SpeechEnded, Error { message: String }, } #[async_trait] pub trait SttProvider: Send + Sync { async fn connect(&mut self, config: &SttConfig) -> Result<()>; async fn send_audio(&mut self, chunk: &[u8]) -> Result<()>; async fn recv_transcript(&mut self) -> Result>; async fn disconnect(&mut self) -> Result>; fn name(&self) -> &str; } // Create provider by name let provider = stt::create_provider("groq-whisper", Some(http_client)); provider.connect(&config).await?; provider.send_audio(&audio_chunk).await?; if let Some(TranscriptEvent::Final { text, .. }) = provider.recv_transcript().await? { println!("Transcript: {}", text); } ``` -------------------------------- ### Manage Global Recording Hotkey Source: https://context7.com/tover0314-w/opentypeless/llms.txt Updates, pauses, or resumes the global hotkey used for recording. ```typescript import { invoke } from '@tauri-apps/api/core' // Update global hotkey await invoke('update_hotkey', { hotkey: 'Ctrl+Shift+Space' }) // Pause hotkey temporarily (for settings UI hotkey capture) await invoke('pause_hotkey') // Resume hotkey after capture await invoke('resume_hotkey') ``` -------------------------------- ### LLM Model Management Source: https://context7.com/tover0314-w/opentypeless/llms.txt Retrieve available models from configured providers. ```APIDOC ## POST fetch_llm_models ### Description Fetches a list of available models from an OpenAI-compatible or Ollama API. ### Request Body - **apiKey** (string) - Required - API key - **baseUrl** (string) - Required - API base URL ### Response - **string[]** - List of available model names. ``` -------------------------------- ### Proxy Cloud STT and LLM Requests Source: https://context7.com/tover0314-w/opentypeless/llms.txt Routes speech-to-text and language model requests through the managed cloud proxy for Pro subscribers. ```typescript import { proxyStt, proxyLlm } from './lib/api' // Cloud STT (for Pro users) const audioBlob = new Blob([audioData], { type: 'audio/wav' }) const { text } = await proxyStt(audioBlob, 'en') console.log('Transcription:', text) // Cloud LLM (for Pro users) const { text: polished } = await proxyLlm([ { role: 'system', content: 'Polish this text for clarity.' }, { role: 'user', content: 'hello how are you doing today' } ]) console.log('Polished:', polished) ``` -------------------------------- ### Define LlmProvider Trait for Pluggable Text Polishing Source: https://context7.com/tover0314-w/opentypeless/llms.txt Implement this trait for custom text polishing backends. Requires configuration and a callback for streaming chunks. ```rust use async_trait::async_trait; use anyhow::Result; pub struct LlmConfig { pub api_key: String, pub model: String, pub base_url: String, pub max_tokens: u32, pub temperature: f64, } pub struct PolishRequest { pub raw_text: String, pub app_type: AppType, pub dictionary: Vec, pub translate_enabled: bool, pub target_lang: String, pub selected_text: Option, } pub struct PolishResponse { pub polished_text: String, } pub type ChunkCallback = Box; #[async_trait] pub trait LlmProvider: Send + Sync { async fn polish( &self, config: &LlmConfig, req: &PolishRequest, on_chunk: Option<&ChunkCallback>, ) -> Result; fn name(&self) -> &str; } ``` -------------------------------- ### Check Cloud Subscription Status Source: https://context7.com/tover0314-w/opentypeless/llms.txt Retrieves current subscription plan and usage limits for cloud-based features. ```typescript import { getSubscriptionStatus, type SubscriptionStatus } from './lib/api' const status: SubscriptionStatus = await getSubscriptionStatus() console.log('Plan:', status.plan) // 'free' | 'pro' console.log('STT Usage:', `${status.sttSecondsUsed}/${status.sttSecondsLimit} seconds`) console.log('LLM Usage:', `${status.llmTokensUsed}/${status.llmTokensLimit} tokens`) if (status.subscriptionEnd) { console.log('Subscription ends:', status.subscriptionEnd) } ``` -------------------------------- ### Conventional Commit Format Source: https://github.com/tover0314-w/opentypeless/blob/main/CONTRIBUTING.md Template for writing commit messages following the Conventional Commits specification. ```text : [optional body] ``` -------------------------------- ### Test STT and LLM Connectivity Source: https://context7.com/tover0314-w/opentypeless/llms.txt Verifies API connectivity for STT and LLM providers. Returns a boolean indicating success. ```typescript import { invoke } from '@tauri-apps/api/core' // Test STT provider connection const sttOk: boolean = await invoke('test_stt_connection', { apiKey: 'gsk_xxxxxxxxxxxx', provider: 'groq-whisper' }) console.log('STT connection:', sttOk ? 'Success' : 'Failed') // Test LLM provider connection const llmOk: boolean = await invoke('test_llm_connection', { apiKey: 'sk-or-v1-xxxxxxxxxxxx', provider: 'openrouter', baseUrl: 'https://openrouter.ai/api/v1', model: 'google/gemini-2.5-flash' }) console.log('LLM connection:', llmOk ? 'Success' : 'Failed') ``` -------------------------------- ### Fetch Available LLM Models Source: https://context7.com/tover0314-w/opentypeless/llms.txt Retrieves a list of models from an OpenAI-compatible or Ollama API endpoint. ```typescript import { invoke } from '@tauri-apps/api/core' // Fetch models from OpenRouter const models: string[] = await invoke('fetch_llm_models', { apiKey: 'sk-or-v1-xxxxxxxxxxxx', baseUrl: 'https://openrouter.ai/api/v1' }) console.log('Available models:', models) // Output: ['anthropic/claude-3.5-sonnet', 'google/gemini-2.5-flash', 'openai/gpt-4o', ...] // Fetch models from local Ollama const ollamaModels: string[] = await invoke('fetch_llm_models', { apiKey: '', baseUrl: 'http://localhost:11434/api' }) console.log('Ollama models:', ollamaModels) // Output: ['llama3.2', 'mistral', 'codellama', ...] ``` -------------------------------- ### Abort Recording Pipeline Source: https://context7.com/tover0314-w/opentypeless/llms.txt Immediately cancels the recording pipeline and resets the application state to idle. This is useful for stopping the process abruptly. ```typescript import { invoke } from '@tauri-apps/api/core' // Abort pipeline - immediately cancel and reset to idle await invoke('abort_recording') ``` -------------------------------- ### Define TextOutput Trait for Output Modes Source: https://context7.com/tover0314-w/opentypeless/llms.txt Implement this trait to define how polished text is delivered to applications, supporting modes like keyboard simulation or clipboard. ```rust use async_trait::async_trait; use anyhow::Result; pub enum OutputMode { Keyboard, // Simulate keystrokes using enigo Clipboard, // Copy to clipboard and paste } #[async_trait] pub trait TextOutput: Send + Sync { async fn type_text(&self, text: &str) -> Result<()>; fn mode(&self) -> OutputMode; } ``` -------------------------------- ### Benchmark STT and LLM Latency Source: https://context7.com/tover0314-w/opentypeless/llms.txt Measures round-trip latency to providers in milliseconds. ```typescript import { invoke } from '@tauri-apps/api/core' // Benchmark STT latency const sttLatency: number = await invoke('bench_stt_connection', { apiKey: 'gsk_xxxxxxxxxxxx', provider: 'groq-whisper' }) console.log(`STT latency: ${sttLatency}ms`) // Benchmark LLM latency const llmLatency: number = await invoke('bench_llm_connection', { apiKey: 'sk-or-v1-xxxxxxxxxxxx', provider: 'openrouter', baseUrl: 'https://openrouter.ai/api/v1', model: 'google/gemini-2.5-flash' }) console.log(`LLM latency: ${llmLatency}ms`) ``` -------------------------------- ### Recording Control API Source: https://context7.com/tover0314-w/opentypeless/llms.txt API endpoints for controlling the audio recording and transcription pipeline. ```APIDOC ## POST /start_recording ### Description Initiates the recording pipeline. Captures audio from the default microphone, streams it to the configured STT provider, and begins transcription. The pipeline emits real-time events for partial transcripts, volume levels, and state changes. ### Method POST ### Endpoint /start_recording ### Parameters None ### Request Example ```typescript import { invoke } from '@tauri-apps/api/core' await invoke('start_recording') ``` ### Response #### Success Response (200) This command does not return a value directly but triggers events. #### Events - `pipeline:state`: Emits the current state of the pipeline ('idle', 'recording', 'transcribing', 'polishing', 'outputting'). - `audio:volume`: Emits the current audio volume level (0.0 - 1.0). - `stt:partial`: Emits partial transcriptions as they are generated. ## POST /stop_recording ### Description Stops recording and triggers the full pipeline: finalize STT, polish with LLM (if enabled), and output text. Captures selected text from the foreground app for LLM context if enabled. ### Method POST ### Endpoint /stop_recording ### Parameters None ### Request Example ```typescript import { invoke } from '@tauri-apps/api/core' await invoke('stop_recording') ``` ### Response #### Success Response (200) This command does not return a value directly but triggers events. #### Events - `llm:chunk`: Emits streaming chunks from the LLM during the polish phase. - `pipeline:error`: Emits any errors encountered during the pipeline execution. - `pipeline:timing`: Emits timing metrics for different stages of the pipeline (stt_ms, llm_ms, total_ms, recording_ms). ## POST /abort_recording ### Description Immediately cancels the pipeline regardless of current state. Stops audio capture, clears accumulated text, and resets to idle state. ### Method POST ### Endpoint /abort_recording ### Parameters None ### Request Example ```typescript import { invoke } from '@tauri-apps/api/core' await invoke('abort_recording') ``` ### Response #### Success Response (200) This command does not return a value directly but resets the pipeline to idle state. ``` -------------------------------- ### Manage Transcription History Source: https://context7.com/tover0314-w/opentypeless/llms.txt Retrieves paginated history from the local SQLite database or clears all entries. ```typescript import { invoke } from '@tauri-apps/api/core' interface HistoryEntry { id: number created_at: string app_name: string app_type: string raw_text: string polished_text: string language: string | null duration_ms: number | null } // Get history with pagination const history: HistoryEntry[] = await invoke('get_history', { limit: 50, offset: 0 }) history.forEach(entry => { console.log(`[${entry.created_at}] ${entry.app_name}`) console.log(` Raw: ${entry.raw_text}`) console.log(` Polished: ${entry.polished_text}`) }) // Clear all history await invoke('clear_history') ``` -------------------------------- ### History Management Source: https://context7.com/tover0314-w/opentypeless/llms.txt Manage transcription history stored in the local SQLite database. ```APIDOC ## POST get_history ### Request Body - **limit** (number) - Required - Number of records to fetch - **offset** (number) - Required - Pagination offset ## POST clear_history - Clears all records from the history database. ``` -------------------------------- ### Manage Custom Dictionary Source: https://context7.com/tover0314-w/opentypeless/llms.txt Performs CRUD operations on the custom dictionary used to improve transcription accuracy. ```typescript import { invoke } from '@tauri-apps/api/core' interface DictionaryEntry { id: number word: string pronunciation: string | null } // Get all dictionary entries const dictionary: DictionaryEntry[] = await invoke('get_dictionary') // Add a new term (pronunciation is optional) await invoke('add_dictionary_entry', { word: 'OpenTypeless', pronunciation: 'oh-pen-type-less' }) // Add technical term without pronunciation await invoke('add_dictionary_entry', { word: 'Kubernetes', pronunciation: null }) // Remove entry by ID await invoke('remove_dictionary_entry', { id: 1 }) ``` -------------------------------- ### Dictionary Management Source: https://context7.com/tover0314-w/opentypeless/llms.txt Manage custom dictionary entries for improved transcription accuracy. ```APIDOC ## POST get_dictionary - Returns all dictionary entries. ## POST add_dictionary_entry - **word** (string) - Required - The term to add - **pronunciation** (string) - Optional - Phonetic pronunciation ## POST remove_dictionary_entry - **id** (number) - Required - ID of the entry to remove. ``` -------------------------------- ### Set Session Token Source: https://context7.com/tover0314-w/opentypeless/llms.txt Updates the session token used for cloud provider authentication. ```typescript import { invoke } from '@tauri-apps/api/core' // Set session token after OAuth login await invoke('set_session_token', { token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.