Audio sox中的标准化音频:没有这样的文件

Audio sox中的标准化音频:没有这样的文件,audio,sox,Audio,Sox,我正在尝试使用这个脚本使用Sox批量规范化音频。我遇到了一个问题,因为出于某种原因,它似乎没有创建tmp文件,当然也没有标准化的音频文件。每个文件都会出现以下错误: norm_fade.sh: line 57: /Applications/sox/WantNotSamples/Who Am I-temp.wav: No such file or directory Normalized File "wav_file" exists at "/Applications/sox/WantNotSam

我正在尝试使用这个脚本使用Sox批量规范化音频。我遇到了一个问题,因为出于某种原因,它似乎没有创建tmp文件,当然也没有标准化的音频文件。每个文件都会出现以下错误:

norm_fade.sh: line 57: /Applications/sox/WantNotSamples/Who Am I-temp.wav: No such file or directory
Normalized File "wav_file" exists at "/Applications/sox/WantNotSamplesNormalize"
rm: /Applications/sox/WantNotSamples/Who Am I-temp.wav: No such file or directory
这是我的剧本:

#!/bin/sh   
#  Script.sh
#
#
#  Created by scacinto on 1/31/13.
#
#  For now, only put audio files in the working directory - working on a fix

# This is the directory to the source soundfiles that need to be
# normalized and faded (the first argument on the command line.)
src=$1
# This is the directory to write the normalized and faded files to
# (The second path you must supply on the command line.)
dest=$2
#  This is the sox binary directory.  Please set this to your sox path.
#  As it is now, this assumes that the sox binary is in the same directory
#  as the script.
SOX= ./sox

#enable for loops over items with spaces in their name
IFS=$'\n'

#  This is the 'for' loop - it will run for each file in your directory.
for original_file in `ls "$src/"`
do
# Get the base filename of the current wav file
base_filename=`basename "$original_file" .wav`

# We need a temp file name to save the intermediate file as
temp_file="${base_filename}-temp.wav"

echo "Creating temp file: \"$temp_file\" in \"$src\""

# And we need the output WAV file
wav_file="${base_filename}-nf.wav"

# Convert all spaces to hyphens in the output file name
wav_file=`echo $wav_file | tr -s " " "-"`

#Print a progress message
echo "Processing: \"$original_file\". Saving as \"$wav_file\" ..."

# We need the length of the audio file
original_file_length=`$SOX $src/"$original_file" 2>&1 -n stat | grep Length | cut -d : -f 2 | cut -f 1`

# Use sox to add perform the fade-in and fade-out
# saving the result as our temp_file.  Adjust the 0.1s to your desired fade
# times.
#$SOX $src/"$original_file" $src/"$temp_file" fade t 0.1 $original_file_length 0.1

# If files have readable headers, you can skip the above operation to get the
# file length and just use 0 as below.
#$SOX $src/"$original_file" $src/"$temp_file" fade t 0.5 0 0.5

# normalize and write to the output wave file
$SOX $src/"$temp_file" $dest/"$wav_file" norm -0.5

echo "Normalized File \"wav_file\" exists at \"$dest\""

# Delete that temp file
rm $src/$temp_file

done

将用于创建临时文件的行注释掉可能没有帮助。不幸的是,我必须将其作为temp_file=“${base_filename}丢失-temp.wav似乎没有被注释掉。底部的$SOX$src/代码被注释掉,因为它们正在执行我不需要的操作。为变量指定名称并不会创建文件。您有一个注释掉的行,该行调用SOX在temp文件中淡出。这完全正确。我怎么会错过它?感谢您的帮助帮助和编辑@jaket!