summaryrefslogtreecommitdiff
path: root/internal/audio
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-08 08:44:11 +0200
committerPaul Buetow <paul@buetow.org>2026-03-08 08:44:11 +0200
commit6e2635afc69579fdc895d6b7890538ca98dabaae (patch)
tree5db5aa603ab5ac3b372c2ac8512c84627fb063e1 /internal/audio
parentaa733f9a86b02d7b4d6edd8022a44e4ba417b24c (diff)
refactor(task-376): share audio attribution builder
Diffstat (limited to 'internal/audio')
-rw-r--r--internal/audio/attribution.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/internal/audio/attribution.go b/internal/audio/attribution.go
new file mode 100644
index 0000000..80f2bc3
--- /dev/null
+++ b/internal/audio/attribution.go
@@ -0,0 +1,49 @@
+package audio
+
+import (
+ "fmt"
+ "path/filepath"
+ "strings"
+ "time"
+)
+
+// AttributionParams describes metadata included in OpenAI TTS attribution files.
+type AttributionParams struct {
+ Word string
+ Model string
+ Voice string
+ Instruction string
+ ProcessedText string
+ Speed float64
+ GeneratedAt time.Time
+}
+
+// AttributionPath returns the sidecar attribution file path for a generated audio file.
+func AttributionPath(audioFile string) string {
+ return strings.TrimSuffix(audioFile, filepath.Ext(audioFile)) + "_attribution.txt"
+}
+
+// BuildOpenAIAttribution builds the attribution content for OpenAI-generated audio.
+func BuildOpenAIAttribution(params AttributionParams) string {
+ var b strings.Builder
+ b.WriteString("Audio generated by OpenAI TTS\n\n")
+ fmt.Fprintf(&b, "Bulgarian word: %s\n", params.Word)
+ fmt.Fprintf(&b, "Model: %s\n", params.Model)
+ fmt.Fprintf(&b, "Voice: %s\n", params.Voice)
+ fmt.Fprintf(&b, "Speed: %.2f\n", params.Speed)
+
+ if params.Instruction != "" {
+ fmt.Fprintf(&b, "\nVoice instructions:\n%s\n", params.Instruction)
+ }
+ if params.ProcessedText != "" {
+ fmt.Fprintf(&b, "\nProcessed text sent to TTS: %s\n", params.ProcessedText)
+ }
+
+ generatedAt := params.GeneratedAt
+ if generatedAt.IsZero() {
+ generatedAt = time.Now()
+ }
+ fmt.Fprintf(&b, "\nGenerated at: %s\n", generatedAt.Format("2006-01-02 15:04:05"))
+
+ return b.String()
+}