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

TypeError: No format specified and unable to get format from file extension: 'samples/\\.wav' #7

Open
carlosmatthews opened this issue Jun 1, 2021 · 1 comment

Comments

@carlosmatthews
Copy link

When I try to run the program, it recognizes a file older than 1 hour, this error occurs, it seems to have to do with how it names the files into which it segments the original audio. To name the files it uses letters (A-Z) and when the letters are finished it begins to use symbols like: "/". I'm not sure but I think this may be the problem and you should try changing it by using names to name the segments

Traceback (most recent call last):
File "recognize.py", line 60, in
split_into_frames('current.wav')
File "recognize.py", line 55, in split_into_frames
sf.write('samples/{}.wav'.format(chr(int(i/50)+65)), tmp_batch, sr) # new library soundfile as sf remplace librosa.ouput # modificacion carlos
File "C:\Python38\lib\site-packages\soundfile.py", line 314, in write
with SoundFile(file, 'w', samplerate, channels,
File "C:\Python38\lib\site-packages\soundfile.py", line 627, in init
self._info = _create_info_struct(file, mode, samplerate, channels,
File "C:\Python38\lib\site-packages\soundfile.py", line 1416, in _create_info_struct
format = _get_format_from_filename(file, mode)
File "C:\Python38\lib\site-packages\soundfile.py", line 1457, in _get_format_from_filename
raise TypeError("No format specified and unable to get format from "
TypeError: No format specified and unable to get format from file extension: 'samples/\.wav'

@asctime
Copy link

asctime commented Feb 19, 2023

It's just a folder glob, so you can make life much easier just changing the end of 'split_into_frames' (in recognize.py) to something like this:

        # original code:
        #librosa.output.write_wav('samples/{}.wav'.format(chr(int(i/50)+65)), tmp_batch, sr)
        sf.write('samples/{}.wav'.format(int(i/50)), tmp_batch, sr)

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

2 participants