Skip to content

Instantly share code, notes, and snippets.

@Athospd
Created February 14, 2021 20:10
Show Gist options
  • Save Athospd/9e981df8172ec1d53713e758734296f6 to your computer and use it in GitHub Desktop.
Save Athospd/9e981df8172ec1d53713e758734296f6 to your computer and use it in GitHub Desktop.
library(magrittr)
a <- system.file("waves_yesno/1_1_0_1_1_0_1_1.wav", package = "torchaudio")
# mp3 ---------------------------------------------------------------------
a <- system.file("sample_audio_1.mp3", package = "torchaudio")
mp3_bm <- bench::mark(
torchaudio:::av_read_mp3_or_wav(a) %>% torchaudio::transform_to_tensor(),
torchaudio:::tuneR_read_mp3_or_wav(a) %>% torchaudio::transform_to_tensor(),
torchaudio:::av_read_mp3_or_wav(a),
torchaudio:::tuneR_read_mp3_or_wav(a),
av::read_audio_bin(a),
tuneR::readMP3(a),
monitoR::readMP3(a),
check = FALSE
)
a <- system.file("sample_audio_1.mp3", package = "torchaudio")
bench::mark(
torchaudio:::av_read_mp3_or_wav(a),
torchaudio:::av_read_mp3_or_wav(a) %>% torchaudio::transform_to_tensor(),
torchaudio:::tuneR_read_mp3_or_wav(a),
torchaudio:::tuneR_read_mp3_or_wav(a) %>% torchaudio::transform_to_tensor(),
check = FALSE
)
a <- system.file("sample_audio_1.mp3", package = "torchaudio")
bench::mark(
torchaudio:::get_info_mp3(a),
av:::av_media_info(a),
wav =tuneR::readWave(system.file("waves_yesno/1_1_0_1_1_0_1_1.wav", package = "torchaudio"), header = TRUE),
check = FALSE
)
a <- system.file("ARCTIC/cmu_us_aew_arctic/wav/arctic_a0001.wav", package = "torchaudio")
a <- system.file("SpeechCommands/speech_commands_v0.02/seven/0a2b400e_nohash_1.wav", package = "torchaudio")
a <- tempfile(fileext = ".wav")
download.file("https://file-examples-com.github.io/uploads/2017/11/file_example_WAV_10MG.wav", destfile = a)
bench::mark(
torchaudio:::audiofile_read_wav_cpp(a, 0, 999999, "samples"),
tuneR::readWave(a),
av::read_audio_bin(a),
check = FALSE
)
a <- tempfile(fileext = ".mp3")
download.file("https://file-examples-com.github.io/uploads/2017/11/file_example_MP3_5MG.mp3", destfile = a)
bench::mark(
# torchaudio::read_wav(a),
tuneR::readMP3(a),
av::read_audio_bin(a),
check = FALSE
)
wav <- system.file("SpeechCommands/speech_commands_v0.02/seven/0a2b400e_nohash_2.wav", package = "torchaudio")
bench::mark(
iterations = 80,
torchaudio::audiofile_loader(wav),
torchaudio::tuneR_loader(wav),
torchaudio::av_loader(wav),
torchaudio::audiofile_loader(wav) %>% torchaudio::transform_to_tensor(),
torchaudio::tuneR_loader(wav) %>% torchaudio::transform_to_tensor(),
torchaudio::av_loader(wav) %>% torchaudio::transform_to_tensor(),
check = FALSE
)
mp3 <- system.file("sample_audio_1.mp3", package = "torchaudio")
bench::mark(
iterations = 80,
torchaudio::tuneR_loader(mp3),
torchaudio::av_loader(mp3),
torchaudio::tuneR_loader(mp3) %>% torchaudio::transform_to_tensor(),
torchaudio::av_loader(mp3) %>% torchaudio::transform_to_tensor(),
check = FALSE
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment