feat: git init

This commit is contained in:
2026-01-17 19:18:58 -06:00
commit b73d5b8078
18 changed files with 1274 additions and 0 deletions

41
pkg/output/text.go Normal file
View File

@@ -0,0 +1,41 @@
package output
import (
"fmt"
"strings"
"transcribe/internal/whisper"
)
// TextFormatter formats transcription results as plain text with timestamps
type TextFormatter struct{}
// Format converts transcription result to plain text with timestamps
func (f *TextFormatter) Format(result *whisper.TranscriptionResult) (string, error) {
var builder strings.Builder
for _, seg := range result.Segments {
// Format: [MM:SS - MM:SS] [Speaker] Text
startTime := formatTextTimestamp(seg.Start)
endTime := formatTextTimestamp(seg.End)
text := strings.TrimSpace(seg.Text)
if seg.Speaker != "" {
builder.WriteString(fmt.Sprintf("[%s - %s] [%s] %s\n", startTime, endTime, seg.Speaker, text))
} else {
builder.WriteString(fmt.Sprintf("[%s - %s] %s\n", startTime, endTime, text))
}
}
return strings.TrimSuffix(builder.String(), "\n"), nil
}
// formatTextTimestamp converts seconds to MM:SS.s format
func formatTextTimestamp(seconds float64) string {
totalSeconds := int(seconds)
m := totalSeconds / 60
s := totalSeconds % 60
tenths := int((seconds - float64(totalSeconds)) * 10)
return fmt.Sprintf("%02d:%02d.%d", m, s, tenths)
}