mirror of
https://github.com/danielmiessler/Fabric.git
synced 2026-02-12 06:55:08 -05:00
CHANGES - Add --transcribe-file flag to transcribe audio or video - Add --transcribe-model flag with model listing and completion - Add --split-media-file flag to chunk files over 25MB - Implement OpenAI transcription using Whisper and GPT-4o Transcribe - Integrate transcription pipeline into CLI before readability processing - Provide zsh, bash, fish completions for new transcription flags - Validate media extensions and enforce 25MB upload limits - Update README with release and corrected pattern link path
36 lines
948 B
Go
36 lines
948 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/danielmiessler/fabric/internal/core"
|
|
)
|
|
|
|
type transcriber interface {
|
|
TranscribeFile(ctx context.Context, filePath, model string, split bool) (string, error)
|
|
}
|
|
|
|
func handleTranscription(flags *Flags, registry *core.PluginRegistry) (message string, err error) {
|
|
vendorName := flags.Vendor
|
|
if vendorName == "" {
|
|
vendorName = "OpenAI"
|
|
}
|
|
vendor, ok := registry.VendorManager.VendorsByName[vendorName]
|
|
if !ok {
|
|
return "", fmt.Errorf("vendor %s not configured", vendorName)
|
|
}
|
|
tr, ok := vendor.(transcriber)
|
|
if !ok {
|
|
return "", fmt.Errorf("vendor %s does not support audio transcription", vendorName)
|
|
}
|
|
model := flags.TranscribeModel
|
|
if model == "" {
|
|
return "", fmt.Errorf("transcription model is required (use --transcribe-model)")
|
|
}
|
|
if message, err = tr.TranscribeFile(context.Background(), flags.TranscribeFile, model, flags.SplitMediaFile); err != nil {
|
|
return
|
|
}
|
|
return
|
|
}
|