lua---audio icon indicating copy to clipboard operation
lua---audio copied to clipboard

load_and_save_example.lua not working

Open andreiamatuni opened this issue 8 years ago • 7 comments

my code:

require 'audio'

aud, sample_rate = audio.load('what_a_wonderful_world.mp3')

print(#aud)
print(sample_rate)

audio.save('test_out.mp3', aud, sample_rate)

output:

 6094080
       2
[torch.LongStorage of size 2]

test_out.mp3 ends up being an empty mp3 file. input file is 6.2mb, test_out.mp3 is 417 bytes, and duration is 00:00

andreiamatuni avatar Mar 17 '16 07:03 andreiamatuni

I am not able to reproduce the issue. Can you try audio.save with a different output format, such as test_out.ogg or test_out.wav

soumith avatar Mar 20 '16 22:03 soumith

i tried with .wav and it produced a 48.8 mb wav file that seems to be empty/unplayable. When I tried .ogg I got this error message, which might be more informative:

formats: no handler for given file type `ogg'
/Users/andrei/torch/install/bin/luajit: /Users/andrei/torch/install/share/lua/5.1/audio/init.lua:74: [write_audio_file] Failure to open file for writing at /tmp/luarocks_audio-0.1-0-804/lua---audio/generic/sox.c:135
stack traceback:
    [C]: in function 'save'
    /Users/andrei/torch/install/share/lua/5.1/audio/init.lua:74: in function 'save'
    test.lua:9: in main chunk
    [C]: in function 'dofile'
    ...drei/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
    [C]: at 0x010300ebd0

andreiamatuni avatar Mar 21 '16 01:03 andreiamatuni

Does this issue reproduce with audio.samplevoice() or is it just with your specific file?

soumith avatar Mar 21 '16 01:03 soumith

is samplevoice() supposed to return a sample rate? I'm trying to save the tensor that the function returns but it doesn't provide a sample rate so I can pass to the save() function.

andreiamatuni avatar Mar 21 '16 01:03 andreiamatuni

used 41100 as sample rate and it seams to work (though sped up). I guess it's the file I was using. It's a standard mp3 file though, not sure why it's not working.

andreiamatuni avatar Mar 21 '16 01:03 andreiamatuni

I've tried using many different mp3 and wav files as input and none of them worked. Only the sample voice seems to be saving. All the different files look like they're successfully being filled into the tensor, but they result in output files that are empty. Any idea what could be wrong?

andreiamatuni avatar Mar 27 '16 04:03 andreiamatuni

Hello, same problem here (almost). Saving .mp3 results in an unplayable file and .ogg never returns from the call. However .wav seems to work fine. Any update?

dno89 avatar Mar 29 '17 20:03 dno89