Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting large mp3 to wav files - error: Unknown length #14

Closed
Andrechang opened this issue Aug 7, 2016 · 0 comments
Closed

Converting large mp3 to wav files - error: Unknown length #14

Andrechang opened this issue Aug 7, 2016 · 0 comments

Comments

@Andrechang
Copy link

Andrechang commented Aug 7, 2016

I am having issue with loading a large wav file.
So what I did was: I loaded a mp3 file with more than 20min music and then saved it as wav.
But when I load the wav that I just generated it gives the error below:

/home/achang/torch/install/share/lua/5.1/audio/init.lua:56: [read_audio] Unknown length at /tmp/luarocks_audio-0.1-0-130/lua---audio/generic/sox.c:45
stack traceback:
    [C]: in function 'load'
    /home/achang/torch/install/share/lua/5.1/audio/init.lua:56: in function 'load'
    mp3_play.lua:16: in function 'load_file'
    [string "x = load_file('music.wav')"]:1: in main chunk
    [C]: in function 'xpcall'
    /home/achang/torch/install/share/lua/5.1/trepl/init.lua:670: in function 'repl'
    ...hang/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
    [C]: at 0x00405d50

I use the code below to convert:

function convert_mp3_2_wav(file_path)                                            
   local x, sample_rate = audio.load(file_path)                                  
   local outpath = file_path:gsub(".mp3", ".wav")                                                                               
   audio.save(outpath, x, sample_rate)                                           
end

When use a player the wav file sounds fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant