Browse Source

Avoid convert wav audio to wav - refs BT#14921

Whispeak plugin
Angel Fernando Quiroz Campos 6 years ago
parent
commit
1811e278a5
1 changed files with 13 additions and 9 deletions
  1. 13 9
      plugin/whispeakauth/ajax/record_audio.php

+ 13 - 9
plugin/whispeakauth/ajax/record_audio.php

@@ -57,18 +57,22 @@ if (false === $path) {
 }
 
 $originFullPath = api_get_path(SYS_UPLOAD_PATH).'whispeakauth'.$path['path_to_save'];
-$directory = dirname($originFullPath);
-$newFullPath = $directory.'/audio.wav';
+$fileType = mime_content_type($originFullPath);
 
-try {
-    $ffmpeg = FFMpeg::create();
+if ('wav' !== substr($fileType, -3)) {
+    $directory = dirname($originFullPath);
+    $newFullPath = $directory.'/audio.wav';
 
-    $audio = $ffmpeg->open($originFullPath);
-    $audio->save(new Wav(), $newFullPath);
-} catch (Exception $exception) {
-    echo Display::return_message($exception->getMessage(), 'error');
+    try {
+        $ffmpeg = FFMpeg::create();
 
-    exit;
+        $audio = $ffmpeg->open($originFullPath);
+        $audio->save(new Wav(), $newFullPath);
+    } catch (Exception $exception) {
+        echo Display::return_message($exception->getMessage(), 'error');
+
+        exit;
+    }
 }
 
 if ($isEnrollment) {