Browse Source

First commit.

felipe 7 years ago
commit
d581246ace

+ 12 - 0
.idea/AudioSlicer.iml

@@ -0,0 +1,12 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<module type="PYTHON_MODULE" version="4">
3
+  <component name="NewModuleRootManager">
4
+    <content url="file://$MODULE_DIR$" />
5
+    <orderEntry type="inheritedJdk" />
6
+    <orderEntry type="sourceFolder" forTests="false" />
7
+  </component>
8
+  <component name="TestRunnerService">
9
+    <option name="projectConfiguration" value="Nosetests" />
10
+    <option name="PROJECT_TEST_RUNNER" value="Nosetests" />
11
+  </component>
12
+</module>

+ 4 - 0
.idea/misc.xml

@@ -0,0 +1,4 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7.13 (~/anaconda2/bin/python)" project-jdk-type="Python SDK" />
4
+</project>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project version="4">
3
+  <component name="ProjectModuleManager">
4
+    <modules>
5
+      <module fileurl="file://$PROJECT_DIR$/.idea/AudioSlicer.iml" filepath="$PROJECT_DIR$/.idea/AudioSlicer.iml" />
6
+    </modules>
7
+  </component>
8
+</project>

+ 0 - 0
source/__init__.py


+ 32 - 0
source/slice/AudioSlicer.py

@@ -0,0 +1,32 @@
1
+import subprocess
2
+from io import TextIOWrapper
3
+import fs
4
+from networkx.generators.small import desargues_graph
5
+
6
+
7
+class AudioSlicer:
8
+
9
+    destinationDirectory = ""
10
+
11
+    def __init__(self, destinationDirectory):
12
+        self.destinationDirectory = destinationDirectory
13
+
14
+
15
+    def slice(self, audioFilePath, start, duration):
16
+        ' invokes external process'
17
+
18
+        print self.destinationDirectory + " = " + audioFilePath + " - " + start + " - " + duration
19
+
20
+        destinationFile = fs.join(self.destinationDirectory, fs.filename(audioFilePath))
21
+
22
+        command = ['ffmpeg', audioFilePath, '-t', duration, '-ss', start, '-acodec', 'copy', destinationFile]
23
+
24
+        for c in command:
25
+            print c
26
+
27
+        p = subprocess.Popen(['ls', '-l'], stdout=subprocess.PIPE)
28
+
29
+        for line in p.stdout.readlines():
30
+            print line
31
+
32
+

+ 1 - 0
source/slice/__init__.py

@@ -0,0 +1 @@
1
+from source.slice import AudioSlicer

+ 5 - 0
source/starter/Starter.py

@@ -0,0 +1,5 @@
1
+from source.slice import AudioSlicer
2
+
3
+slicer = AudioSlicer('destination')
4
+
5
+slicer.slice('/tmp/audioFile', '00:00:01', '00:00:02')

+ 0 - 0
source/starter/__init__.py


+ 0 - 0
test/__init__.py


+ 12 - 0
test/slice/TestAudioSlicer.py

@@ -0,0 +1,12 @@
1
+import unittest
2
+
3
+
4
+class TestAudioSlicer(unittest.TestCase):
5
+    def test_slice(self):
6
+        self.assertTrue(True)
7
+
8
+    def test_slice_2(self):
9
+        self.assertTrue(True)
10
+
11
+if __name__ == '__main__':
12
+    unittest.main()

+ 1 - 0
test/slice/__init__.py

@@ -0,0 +1 @@
1
+from test.slice import TestAudioSlicer