pass keywords to transcription adapters for spelling hints

This commit is contained in:
leonardotrapani
2026-01-31 20:46:36 +01:00
parent e175f4f6f2
commit 38cac375ad
7 changed files with 36 additions and 1 deletions
+1
View File
@@ -146,6 +146,7 @@ func (c *Config) ToTranscriberConfig() transcriber.Config {
Provider: c.Transcription.Provider,
Language: c.Transcription.Language,
Model: c.Transcription.Model,
Keywords: c.Keywords,
}
// Resolve API key: providers map -> legacy transcription.api_key -> environment variable
@@ -5,6 +5,7 @@ import (
"context"
"fmt"
"log"
"strings"
"time"
"github.com/sashabaranov/go-openai"
@@ -46,6 +47,11 @@ func (a *GroqTranscriptionAdapter) Transcribe(ctx context.Context, audioData []b
Language: a.config.Language,
}
// Add keywords as prompt to help with spelling hints
if len(a.config.Keywords) > 0 {
req.Prompt = strings.Join(a.config.Keywords, ", ")
}
start := time.Now()
resp, err := a.client.CreateTranscription(ctx, req)
duration := time.Since(start)
@@ -5,6 +5,7 @@ import (
"context"
"fmt"
"log"
"strings"
"time"
"github.com/sashabaranov/go-openai"
@@ -49,6 +50,11 @@ func (a *GroqTranslationAdapter) Transcribe(ctx context.Context, audioData []byt
Language: a.config.Language, // Source language hint
}
// Add keywords as prompt to help with spelling hints
if len(a.config.Keywords) > 0 {
req.Prompt = strings.Join(a.config.Keywords, ", ")
}
start := time.Now()
resp, err := a.client.CreateTranslation(ctx, req)
duration := time.Since(start)
+6
View File
@@ -5,6 +5,7 @@ import (
"context"
"fmt"
"log"
"strings"
"time"
"github.com/sashabaranov/go-openai"
@@ -43,6 +44,11 @@ func (a *OpenAIAdapter) Transcribe(ctx context.Context, audioData []byte) (strin
Language: a.config.Language,
}
// Add keywords as initial_prompt to help with spelling hints
if len(a.config.Keywords) > 0 {
req.Prompt = strings.Join(a.config.Keywords, ", ")
}
start := time.Now()
resp, err := a.client.CreateTranscription(ctx, req)
duration := time.Since(start)
+1
View File
@@ -25,6 +25,7 @@ type Config struct {
APIKey string
Language string
Model string
Keywords []string
}
// NewTranscriber creates a new simple transcriber
+15
View File
@@ -78,3 +78,18 @@ Key decisions:
- LLM processing happens between transcription and injection
- Adapter creation and processing errors are logged but don't fail the pipeline
- Sets status to Processing during LLM phase, then back to Injecting
## Task 5: Pass keywords to transcription adapters - COMPLETE
Added Keywords support to transcription adapters:
- Added `Keywords []string` to transcriber.Config struct
- Updated `ToTranscriberConfig()` to pass keywords from config
- OpenAI adapter uses keywords in `Prompt` field (initial_prompt parameter)
- Groq transcription adapter uses keywords in `Prompt` field
- Groq translation adapter uses keywords in `Prompt` field
- Mistral and ElevenLabs adapters ignore keywords (APIs don't support initial_prompt)
Key decisions:
- Keywords joined with ", " to form a single string for the Prompt field
- Whisper uses this as "initial_prompt" to help with spelling/terminology
- Only added to adapters that clearly support it (OpenAI/Groq via go-openai lib)
+1 -1
View File
@@ -101,7 +101,7 @@
"Non-supporting transcribers still work",
"Typecheck passes"
],
"passes": false
"passes": true
},
{
"title": "Add TUI dependencies and base components",