pass keywords to transcription adapters for spelling hints
This commit is contained in:
@@ -146,6 +146,7 @@ func (c *Config) ToTranscriberConfig() transcriber.Config {
|
|||||||
Provider: c.Transcription.Provider,
|
Provider: c.Transcription.Provider,
|
||||||
Language: c.Transcription.Language,
|
Language: c.Transcription.Language,
|
||||||
Model: c.Transcription.Model,
|
Model: c.Transcription.Model,
|
||||||
|
Keywords: c.Keywords,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve API key: providers map -> legacy transcription.api_key -> environment variable
|
// Resolve API key: providers map -> legacy transcription.api_key -> environment variable
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sashabaranov/go-openai"
|
"github.com/sashabaranov/go-openai"
|
||||||
@@ -46,6 +47,11 @@ func (a *GroqTranscriptionAdapter) Transcribe(ctx context.Context, audioData []b
|
|||||||
Language: a.config.Language,
|
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()
|
start := time.Now()
|
||||||
resp, err := a.client.CreateTranscription(ctx, req)
|
resp, err := a.client.CreateTranscription(ctx, req)
|
||||||
duration := time.Since(start)
|
duration := time.Since(start)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sashabaranov/go-openai"
|
"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
|
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()
|
start := time.Now()
|
||||||
resp, err := a.client.CreateTranslation(ctx, req)
|
resp, err := a.client.CreateTranslation(ctx, req)
|
||||||
duration := time.Since(start)
|
duration := time.Since(start)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sashabaranov/go-openai"
|
"github.com/sashabaranov/go-openai"
|
||||||
@@ -43,6 +44,11 @@ func (a *OpenAIAdapter) Transcribe(ctx context.Context, audioData []byte) (strin
|
|||||||
Language: a.config.Language,
|
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()
|
start := time.Now()
|
||||||
resp, err := a.client.CreateTranscription(ctx, req)
|
resp, err := a.client.CreateTranscription(ctx, req)
|
||||||
duration := time.Since(start)
|
duration := time.Since(start)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ type Config struct {
|
|||||||
APIKey string
|
APIKey string
|
||||||
Language string
|
Language string
|
||||||
Model string
|
Model string
|
||||||
|
Keywords []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTranscriber creates a new simple transcriber
|
// NewTranscriber creates a new simple transcriber
|
||||||
|
|||||||
@@ -78,3 +78,18 @@ Key decisions:
|
|||||||
- LLM processing happens between transcription and injection
|
- LLM processing happens between transcription and injection
|
||||||
- Adapter creation and processing errors are logged but don't fail the pipeline
|
- Adapter creation and processing errors are logged but don't fail the pipeline
|
||||||
- Sets status to Processing during LLM phase, then back to Injecting
|
- 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
@@ -101,7 +101,7 @@
|
|||||||
"Non-supporting transcribers still work",
|
"Non-supporting transcribers still work",
|
||||||
"Typecheck passes"
|
"Typecheck passes"
|
||||||
],
|
],
|
||||||
"passes": false
|
"passes": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"title": "Add TUI dependencies and base components",
|
"title": "Add TUI dependencies and base components",
|
||||||
|
|||||||
Reference in New Issue
Block a user