Sox Batch Process Under Debian

Sox batch process under Debian

Summary: It is the quote symbols

The problem is with the double-quotes:

for f in *.wav; do sox “$f” -r 48000 “${f%%%.wav}.wav”; done

The double-quotes above are non-standard. For them to be properly processed by the shell, the standard ASCII quote symbol must be used:

for f in ./*.wav; do sox "$f" -r 48000 "${f%%%.wav}.wav"; done

As an aside, note that ${f%%%.wav} removes any occurrences of %.wav from the end of the input file name. ${f%%%.wav}.wav adds one .wav back on to the end after removing any %.wav suffixes. You likely want something else here.

Verification

Using the bad quote characters, as per the question, observe the error message:

$ for f in *.wav; do sox “$f” -r 48000 “${f%%%.wav}.wav”; done
sox FAIL formats: can't open input file `“90.wav”': No such file or directory

Note the file name in the error message is shown with two-sets of quotes around the file name. This is what you saw as per the error message that in the question. The outer single-quotes are supplied by sox. The inner double-quotes are the funny quote characters provided on the command line. Because they are non-standard characters, the shell left them in place and passed them to the sox command.

While the file 90.wav exists, no file by the name of “90.wav” exists. Hence, the error.

Conclusion

Stick to standard ASCII characters for shell commands.

This issue can easily happen if the shell commands are typed in using a fancy word-processing editor that substitutes in typographically-pretty but non-standard characters. As tripleee points out, it can also happen when copying-and-pasting from the websites with inappropriate typographical styling.

Batch process wav files with sox within subfolders

This is how I would do it:

@ECHO OFF
SET "_sox=C:\Program Files (x86)\sox-14-4-2\sox.exe"

FOR /F "usebackq delims=" %%A IN (`DIR /B "%~dp0"`) DO (
MKDIR "%~dp0\%%A\Mono" 2> NUL
FOR /F "usebackq delims=" %%B IN (`DIR /B "%~dp0\%%A\*.wav"`) DO (
"%_sox%" -S "%~dp0\%%A\%%B" "%~dp0\%%A\Mono\%%~nB.wav" channels 1
)
)

DIR /B lists every file and folder within the specified folder.

For each folder it finds, it will create a Mono folder within it, and then run the sox command for each .wav file found.

Hope this helps. Love your name btw

Making chunks of audio files using SoX if start and end times are known

I found that the simplest solution is to write the command as such:

sox infile outfile start =end

The audio is not sent to the output stream until the start location is reached and specifying an end location can be done by using the "=" sign with the end time.

So the code would now be, for instance:

sox forth.wav 10.wav trim 303.463 =353.790
  1. Link to the docs http://manpages.ubuntu.com/manpages/precise/man1/sox.1.html
  2. Relevant excerpt:

trim start [length|=end]
The optional length parameter gives the length of audio to
output after the start sample and is thus used to trim off the
end of the audio. Alternatively, an absolute end location can
be given by preceding it with an equals sign. Using a value of
0 for the start parameter will allow trimming off the end only.

How to use sox with an audio file list

If you have a list of the files that you want merged in MergeList.txt and it looks like this:

fileRandomID1.wav
fileRandomID2.wav
fileRandomID3.wav

You can do:

sox -m $(cat MergeList.txt) output.wav

Batch process in V2 supported?

No. Without devkit, batch process is not possible. Batch support is present in V2 but it sends each request separately. For Ex - for 10 objects, there will be 10 different transactions(IO).

https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0100_ipp_.net_devkit/0300_asynchronous_calls/2_batch_process

Just fyi - Actual batch operation support is available in V3.
For ex - 10 objects can be created(or any other CRUD operations), using only 1 transaction.

V3 - https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v3/020_key_concepts/00700_batch_operation

.net devkit - https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0201_ipp_java_devkit_3.0

Thanks

Linux command to extend the duration of audio files

Use

sox -n silence.wav trim 0.55

to generate a 0.55s long file of silence.

Then

sox -m -v 1 yourfile.wav silence.wav -t wav outfile

batch trim wav files using sox

You are using the for-loop on a wrong way. You have to provide the files you want to iterate through between the parenthesis. %* actually means "all arguments". You need something like *.wav (which means all files in the current folder ending with ".wav") or * (meaning all files in current folder).
You also may want to use %%~A inside your double quotes too. It will remove surrounding double quotes if they already were present in %%A, else you may have double pairs of double quotes (for eg ""this should be one string"") and the effect of the double quotes will be undone. And are you sure about the "trimmed\%%~nA" part? With the ~n you're leaving out the extension of the filename (if %%A would be original.wav, %%~nA will become original). Use ~nx if you want filename and the extension at the end (see link at the end).

Here is the loop you should have:

FOR %%A IN (*.wav) DO sox "%%~A" "trimmed\%%~nA" trim 15

if you do want to have the extension in the "trimmed\%%~nA" part, replace it with "trimmed\%%~nxA"

This link talks about the different for-loops in batch.

This link talks about the different path manipulation techniques you can use on arguments and loop-variables



Related Topics



Leave a reply



Submit