write a script to convert an mp3 audio file to a wav format with 16 kHz sampling rate
- User
write a script to convert an mp3 audio file to a wav format with 16 kHz sampling rate
Assistant
Here is a sample bash script to convert an mp3 audio file to a wav format with 16 kHz sampling rate using the
ffmpegcommand-line tool:#!/bin/bash # Check if the required argument is provided if [ "$#" -ne 1 ]; then echo "Usage: $0 <input_mp3_file>" exit 1 fi # Check if input file exists if [ ! -f "$1" ]; then echo "Error: Input file does not exist." exit 1 fi # Extract the base name of the input file input_base=$(basename -- "$1") input_name="${input_base%.*}" # Set the output file name output_file="$input_name.wav" # Convert the input mp3 file to a wav file with 16 kHz sampling rate ffmpeg -i "$1" -ar 16000 "$output_file" # Check if the conversion was successful if [ $? -eq 0 ]; then echo "Successfully converted $1 to $output_file" else echo "Error: Failed to convert $1 to $output_file" exit 1 fi
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.