utils

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package utils provides utility functions for audio processing and common operations. This file contains audio-specific utilities including duration measurement, word counting, WPM calculations, and clamping functions.

Key features:

  • Audio duration measurement (macOS afinfo)
  • Word counting and WPM calculations
  • Duration estimation utilities
  • Value clamping functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateWPM

func CalculateWPM(wordCount int, durationSeconds float64) float64

CalculateWPM calculates words per minute given word count and duration. Duration should be in seconds. Returns 0 if duration is invalid.

func ClampFloat64

func ClampFloat64(value, min, max float64) float64

ClampFloat64 clamps a float64 value between min and max.

func ClampInt

func ClampInt(value, min, max int) int

ClampInt clamps an integer value between min and max.

func CountWords

func CountWords(text string) int

CountWords counts the number of words in a text string. Words are defined as whitespace-separated tokens.

func EstimateDuration

func EstimateDuration(text string, wordsPerMinute float64) float64

EstimateDuration estimates the duration in seconds for a given text at a specified WPM.

func FormatDuration

func FormatDuration(t time.Time) string

FormatDuration formats a time.Time as a human-readable duration from now.

func GetAudioDuration

func GetAudioDuration(audioPath string) (float64, error)

GetAudioDuration measures the duration of an audio file using macOS afinfo. Returns duration in seconds, or an error if the file cannot be read or parsed. This function is macOS-specific and requires the afinfo command.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL