@@ -70,18 +70,18 @@ def get_duration(path: Path) -> str:
7070 return "?"
7171
7272
73- def codec (path : Path ) -> None :
73+ def decode_with_torchcodec (path : Path ) -> None :
7474 AudioDecoder (path ).get_samples_played_in_range (start_seconds = 0 , stop_seconds = None )
7575
7676
77- def audio_stream_reader (path : Path ) -> None :
77+ def decode_with_torchaudio_StreamReader (path : Path ) -> None :
7878 reader = StreamReader (path )
7979 reader .add_audio_stream (frames_per_chunk = 1024 )
8080 for _ in reader .stream ():
8181 pass
8282
8383
84- def audio_load (path : Path , backend : str ) -> None :
84+ def decode_with_torchaudio_load (path : Path , backend : str ) -> None :
8585 torchaudio .load (str (path ), backend = backend )
8686
8787
@@ -102,18 +102,20 @@ def audio_load(path: Path, backend: str) -> None:
102102 f"Benchmarking { path .name } , duration: { get_duration (path )} , averaging over { args .num_exp } runs:"
103103)
104104
105- times = bench (codec , path , num_exp = args .num_exp )
105+ times = bench (decode_with_torchcodec , path , num_exp = args .num_exp )
106106report_stats (times , prefix = "torchcodec.AudioDecoder" )
107107
108- times = bench (audio_load , path , backend = "ffmpeg" , num_exp = args .num_exp )
108+ times = bench (decode_with_torchaudio_load , path , backend = "ffmpeg" , num_exp = args .num_exp )
109109report_stats (times , prefix = "torchaudio.load(backend='ffmpeg')" )
110110
111111prefix = "torchaudio.load(backend='sox')"
112112try :
113- times = bench (audio_load , path , backend = "sox" , num_exp = args .num_exp )
113+ times = bench (
114+ decode_with_torchaudio_load , path , backend = "sox" , num_exp = args .num_exp
115+ )
114116 report_stats (times , prefix = prefix )
115117except RuntimeError :
116118 print (f"{ prefix :<40} Not supported" )
117119
118- times = bench (audio_stream_reader , path , num_exp = args .num_exp )
120+ times = bench (decode_with_torchaudio_StreamReader , path , num_exp = args .num_exp )
119121report_stats (times , prefix = "torchaudio.StreamReader" )
0 commit comments