general refactor for simpler code

This commit is contained in:
LeonardoTrapani
2025-08-16 22:07:06 +02:00
parent 5f90c1c2d5
commit e8fd6c1d49
6 changed files with 147 additions and 213 deletions
+11 -1
View File
@@ -3,6 +3,7 @@ package transcriber
import (
"context"
"fmt"
"os"
"github.com/leonardotrapani/hyprvoice/internal/recording"
)
@@ -11,7 +12,7 @@ import (
type Transcriber interface {
Start(ctx context.Context, frameCh <-chan recording.AudioFrame) (<-chan error, error)
Stop(ctx context.Context) error
GetTranscription() (string, error)
GetFinalTranscription() (string, error)
}
// Adapter interface for different transcription backends
@@ -59,3 +60,12 @@ func NewTranscriber(config Config) (Transcriber, error) {
return transcriber, nil
}
func NewDefaultTranscriber() (Transcriber, error) {
config := DefaultConfig()
if apiKey := os.Getenv("OPENAI_API_KEY"); apiKey != "" {
config.APIKey = apiKey
}
return NewTranscriber(config)
}