Skip to content

Commit

Permalink
added audio_duration util
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarx committed Oct 2, 2022
1 parent 5d3f8ca commit afa4dba
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions vktrs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ def gpu_info():
return pd.DataFrame({' '.join(k.strip().split('.')).capitalize():v for k,v in zip(header.split(','), rec.split(','))}, index=[0]).T


def get_audio_duration_seconds(audio_fpath):
outv = subprocess.run([
'ffprobe'
,'-i',audio_fpath
,'-show_entries', 'format=duration'
,'-v','quiet'
,'-of','csv=p=0'
],
stdout=subprocess.PIPE
).stdout.decode('utf-8')
return float(outv.strip())


def remove_punctuation(s):
# https://stackoverflow.com/a/266162/819544
return s.translate(str.maketrans('', '', string.punctuation))
Expand Down

0 comments on commit afa4dba

Please sign in to comment.