Bladeren bron

[dependency] replacing ffmpeg by avconv for raspebrry support

ThiBuff 7 jaren geleden
bovenliggende
commit
51a069e81c

+ 0 - 1
.travis.yml

@@ -14,7 +14,6 @@ before_install:
 - sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse"
 - sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse"
 - sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse"
-- sudo add-apt-repository ppa:mc3man/trusty-media
 - sudo apt-get update
 - sudo apt-get install $(cat install/files/deb-packages_requirements.txt)
 - sudo apt-get install libstdc++6

+ 0 - 1
install/files/deb-packages_requirements.txt

@@ -21,4 +21,3 @@ sox
 libatlas3-base
 mplayer
 libav-tools
-ffmpeg

+ 0 - 1
install/files/travis_repo_trusty_requirements.txt

@@ -1,4 +1,3 @@
 "deb http://archive.ubuntu.com/ubuntu trusty main restricted universe multiverse"
 "deb http://archive.ubuntu.com/ubuntu trusty-updates main restricted universe multiverse"
 "deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse"
-ppa:mc3man/trusty-media

+ 1 - 2
install/rpi_install_kalliope.sh

@@ -27,8 +27,7 @@ echo "Installing system packages..."
 sudo apt-get update
 sudo apt-get install -y git python-dev libsmpeg0 libttspico-utils libsmpeg0 \
 flac dialog libffi-dev libffi-dev libssl-dev portaudio19-dev build-essential \
-libssl-dev libffi-dev sox libatlas3-base mplayer libyaml-dev libpython2.7-dev pulseaudio pulseaudio-utils libav-tools \
-ffmpeg
+libssl-dev libffi-dev sox libatlas3-base mplayer libyaml-dev libpython2.7-dev pulseaudio pulseaudio-utils libav-tools
 
 # this is used to help the RPI
 sudo apt-get install -y libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev

+ 16 - 6
kalliope/core/RestAPI/FlaskAPI.py

@@ -230,12 +230,7 @@ class FlaskAPI(threading.Thread):
         audio_path = base_path + os.sep + filename
         logger.debug("[FlaskAPI] run_synapse_by_audio: with file path %s" % audio_path)
         if not self.allowed_file(audio_path):
-            # Not allowed so convert into wav using ffmpeg
-            base = os.path.splitext(audio_path)[0]
-            new_file_path = base + ".wav"
-            os.system("ffmpeg -y -i " + audio_path + " " + new_file_path) # --> deprecated
-            # subprocess.call(['ffmpeg', '-y', '-i', audio_path, new_file_path], shell=True) # Not working ...
-            audio_path = new_file_path
+            audio_path = self._convert_to_wav(audio_file_path=audio_path)
         ol = OrderListener(callback=self.audio_analyser_callback, audio_file_path=audio_path)
         ol.start()
         ol.join()
@@ -254,6 +249,21 @@ class FlaskAPI(threading.Thread):
             }
             return jsonify(error=data), 400
 
+    @staticmethod
+    def _convert_to_wav(audio_file_path):
+        """
+        Convert an incoming audio file to wav format. Using either system avconv (raspberry)
+        :param audio_file_path: the current file path
+        :return: new Wave file path
+        """
+        # Not allowed so convert into wav using avconv (raspberry)
+        base = os.path.splitext(audio_file_path)[0]
+        new_file_path = base + ".wav"
+        os.system("avconv -y -i " + audio_file_path + " " + new_file_path)  # --> deprecated
+        # subprocess.call(['avconv', '-y', '-i', audio_path, new_file_path], shell=True) # Not working ...
+
+        return new_file_path
+
     @requires_auth
     def shutdown_server(self):
         func = request.environ.get('werkzeug.server.shutdown')