AI-API-AR / functions /utils.py
Anicet
first commit
b62fe62
Raw
History Blame Contribute Delete
289 Bytes
import soundfile as sf
def getAudioDuration(filePath: str) -> float:
try:
data, samplerate = sf.read(filePath)
duration = len(data) / samplerate
return duration
except Exception as e:
print(f"Error getting audio duration: {e}")
return 0.0