changeset 289:69ca1c64a9b0

Return 'wav' when 'wave' is guessed in _guess_audio_format
author Amine Sehili <amine.sehili@gmail.com>
date Sat, 05 Oct 2019 14:26:03 +0200
parents 41a93cc1ced9
children 2878d2f83282
files auditok/io.py tests/test_io.py
diffstat 2 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/auditok/io.py	Fri Oct 04 22:02:37 2019 +0100
+++ b/auditok/io.py	Sat Oct 05 14:26:03 2019 +0200
@@ -95,8 +95,14 @@
 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()
+        if extension:
+            fmt = extension
+        else:
+            return None
+    fmt == fmt.lower()
+    if fmt == "wave":
+        fmt = "wav"
+    return fmt
 
 
 def _normalize_use_channel(use_channel):
--- a/tests/test_io.py	Fri Oct 04 22:02:37 2019 +0100
+++ b/tests/test_io.py	Sat Oct 05 14:26:03 2019 +0200
@@ -67,6 +67,8 @@
         extention_no_format=(None, "filename.wav", "wav"),
         format_no_extension=("wav", "filename", "wav"),
         no_format_no_extension=(None, "filename", None),
+        wave_as_wav=("wave", "filename", "wav"),
+        wave_as_wav_extension=(None, "filename.wave", "wav"),
     )
     def test_guess_audio_format(self, fmt, filename, expected):
         result = _guess_audio_format(fmt, filename)