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
@@ -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