# HG changeset patch # User Amine Sehili # Date 1546974858 -3600 # Node ID cee5037f17adf145e0842341ec17c14ffbb770dd # Parent ccab869cdbcbaf9ffeb316b546b55429d2bd3748 Add _guess_audio_format diff -r ccab869cdbcb -r cee5037f17ad auditok/io.py --- a/auditok/io.py Mon Jan 07 21:12:10 2019 +0100 +++ b/auditok/io.py Tue Jan 08 20:14:18 2019 +0100 @@ -52,6 +52,13 @@ "multiple of `sample_width * channels`") +def _guess_audio_format(fmt, filename): + if fmt is None: + extension = os.path.splitext(filename.lower())[1][1:] + return extension if extension else None + return fmt.lower() + + class AudioSource(): """ Base class for audio source objects.