| audio_convert | R Documentation |
Re-encode an audio (or A/V) file's audio to a new container, sample rate, channel count, or codec via ffmpeg. The output format is inferred from the output extension. With no optional arguments it is a straight transcode.
audio_convert(input, output, sample_rate = NULL, channels = NULL,
bitrate = NULL, codec = NULL, overwrite = TRUE, dry_run = FALSE)
input |
Path to input audio (or A/V) file. |
output |
Path for output file; extension selects the format. |
sample_rate |
Output sample rate in Hz, or NULL to keep the source rate. |
channels |
Output channel count (1 = mono, 2 = stereo), or NULL to keep. |
bitrate |
Output audio bitrate (e.g. "192k"), or NULL for the encoder default. Ignored by lossless formats such as WAV. |
codec |
Explicit audio codec (e.g. "libmp3lame", "pcm_s16le"), or NULL to let ffmpeg pick from the output extension. |
overwrite |
If TRUE (default), overwrite the output file. |
dry_run |
If TRUE, return the ffmpeg command without executing. |
Resampling to 16 kHz mono is the usual preparation for speech-to-text:
audio_convert("audio.mp3", "audio.wav", sample_rate = 16000).
Invisibly returns the output path. If dry_run, returns the command string.
## Not run:
audio_convert("audio.mp3", "speech.wav", sample_rate = 16000)
audio_convert("take.wav", "take.mp3", bitrate = "192k")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.